编译错误:软件包javax.servlet不存在 [英] Compile error: package javax.servlet does not exist

查看:758
本文介绍了编译错误:软件包javax.servlet不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包,其中我导入javax.servlet。*和javax.servlet.http。*
当我尝试在命令提示符编译它,我得到错误

I have a package in which I import javax.servlet.* and javax.servlet.http.* When I try to compile it in command prompt I get the error


包javax.servlet不存在

package javax.servlet does not exist

我使用JDK 1.7.0和Tomcat 6.0。

I use JDK 1.7.0 and Tomcat 6.0.

推荐答案

您需要将路径添加到Tomcat 6的 / lib / servlet-api。 jar 文件到编译时类路径。

You need to add the path to Tomcat 6's /lib/servlet-api.jar file to the compile time classpath.

javac -cp .;/path/to/Tomcat/lib/servlet-api.jar com/example/MyServletClass.java

类路径是Java需要查找导入的依赖关系的地方。否则它将默认为包含在中的当前文件夹。在上面的示例中。 ; 是Windows的路径分隔符;如果您使用的是基于Unix的操作系统,则需要使用

The classpath is where Java needs to look for imported dependencies. It will otherwise default to the current folder which is included as . in the above example. The ; is the path separator for Windows; if you're using an Unix based OS, then you need to use : instead.

这篇关于编译错误:软件包javax.servlet不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆