怎样解决这个错误呢??????

ca4658 2001-08-20 05:23:55
我装了JDK,设好了路径后,
tomcat的路径是c:\tomcat
jdk1.3的路径是c:\jdk

PATH=C:\JDK\BIN;C:\WINDOWS;c:\jdk
set CLASSPATH=.;C:\JDK\lib\dt.jar;c:\JDK\lib\tools.jar;c:\tomcat\bin\servlet.jar
set JAVA_HOME=c:\JDK
set TOMCAT_HOME=c:\tomcat

在tomcat里面建了一个new\WEB-INF\classes目录,建了一个gm.java文件,
源文件内容:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class gm extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse res)
throws ServletException,IOException
{
res.setContentType("text/html;charset=Big5");
PrintWriter pw=res.getWriter();
pw.println("<HTML>");
pw.println("<Body>");
pw.println("<b2>good morning</b2>");
pw.println("</body>");
pw.println("</html>");
}
}
在里面执行javac gm.java时
出现在下面的错误:
请各位大侠指教一下,我哪里错误了。

gm.java:2:包 javax.servlet 不存在
import javax.servlet.*;
^
gm.java:3:包 javax.servlet.http不存在
import javax.servlet.http.*;
^
gm.java:4: 不能解析符号
符号:类HttpServlet
位置:类in gm
public class gm extends HttpServlet

gm.java:6: 不能解析符号
符号:类HttpServlet
位置:类in gm
public void service(HttpServletRequest req,HttpServletResponse res)

gm.java:6:不能解析符号
符号:类HttpServlet
位置:类in gm
public void service(HttpServletRequest req,HttpServletResponse res)

gm.java:7:不能解析符号
符号:类ServletException
位置:类in gm
throws ServletException,IOException
6个错误
...全文
52 点赞 收藏 4
写回复
4 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
ca4658 2001-08-21
多谢两位。
分我会给
回复
lci21 2001-08-20
如果问题解决了,给分啊,呵呵
回复
lci21 2001-08-20
你的下面一具有问题:
set CLASSPATH=.;C:\JDK\lib\dt.jar;c:\JDK\lib\tools.jar;c:\tomcat\bin\servlet.jar
你如果是jdk1.4以前的版本,
c:\tomcat\bin\servlet.jar
应该改为:
c:\tomcat\lib\servlet.jar
回复
lci21 2001-08-20
再你的CLASSPATH中指明servlet.jar的路径
我的是:D:\TOMCAT\lib\servlet.jar
javax.servlet包包含的类主要有:
F:\java>jar -ft servlet.jar
META-INF/
META-INF/MANIFEST.MF
javax/
javax/servlet/
javax/servlet/http/
javax/servlet/jsp/
javax/servlet/jsp/tagext/
javax/servlet/http/Cookie.class
javax/servlet/http/HttpServlet.class
javax/servlet/http/NoBodyResponse.class
javax/servlet/http/NoBodyOutputStream.class
javax/servlet/http/HttpServletRequest.class
javax/servlet/http/HttpServletResponse.class
javax/servlet/http/HttpSession.class
javax/servlet/http/HttpSessionBindingEvent.class
javax/servlet/http/HttpSessionBindingListener.class
javax/servlet/http/HttpSessionContext.class
javax/servlet/http/HttpUtils.class
javax/servlet/http/LocalStrings.properties
javax/servlet/http/LocalStrings_es.properties
javax/servlet/jsp/tagext/BodyContent.class
javax/servlet/jsp/tagext/BodyTag.class
javax/servlet/jsp/tagext/BodyTagSupport.class
javax/servlet/jsp/tagext/Tag.class
javax/servlet/jsp/tagext/TagAttributeInfo.class
javax/servlet/jsp/tagext/TagData.class
javax/servlet/jsp/tagext/TagExtraInfo.class
javax/servlet/jsp/tagext/TagInfo.class
javax/servlet/jsp/tagext/TagLibraryInfo.class
javax/servlet/jsp/tagext/TagSupport.class
javax/servlet/jsp/tagext/VariableInfo.class
javax/servlet/jsp/HttpJspPage.class
javax/servlet/jsp/JspEngineInfo.class
javax/servlet/jsp/JspException.class
javax/servlet/jsp/JspFactory.class
javax/servlet/jsp/JspPage.class
javax/servlet/jsp/JspTagException.class
javax/servlet/jsp/JspWriter.class
javax/servlet/jsp/PageContext.class
javax/servlet/GenericServlet.class
javax/servlet/RequestDispatcher.class
javax/servlet/Servlet.class
javax/servlet/ServletConfig.class
javax/servlet/ServletContext.class
javax/servlet/ServletException.class
javax/servlet/ServletInputStream.class
javax/servlet/ServletOutputStream.class
javax/servlet/ServletRequest.class
javax/servlet/ServletResponse.class
javax/servlet/SingleThreadModel.class
javax/servlet/UnavailableException.class
javax/servlet/LocalStrings.properties
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2001-08-20 05:23
社区公告
暂无公告