[英]package javax.servlet does not exist - ubuntu, tomcat
echo $CLASSPATH 回声$ CLASSPATH
/home/user/tomcat/lib/server-api.jar
echo $JAVA_HOME 回声$ JAVA_HOME
.:/usr/lib/jvm/java-6-sun
but when I try to compile .java which are in class folder 但是当我尝试编译位于类文件夹中的.java时
javac *.java
I get 我懂了
HelloServlet.java:2: package javax.servlet does not exist
and additional 5 similar errors. 以及另外5个类似的错误。
I get no errors when 当我没有错误
javac -cp /home/user/tomcat/lib/servlet-api.jar *.java
Why is that? 这是为什么? What should I change to make it work without -cp /path?
我应该更改些什么才能使其在没有-cp / path的情况下工作?
Looks like your classpath doesn't actually contain servlet-api.jar . 看起来您的类路径实际上并不包含servlet-api.jar 。 The echo of CLASSPATH shows that it has server-api.jar in the path, but not servlet-api.jar.
CLASSPATH的回显表明它在路径中具有server-api.jar,但没有servlet-api.jar。 Try adding servlet-api.jar to your CLASSPATH definition and see if it works then.
尝试将servlet-api.jar添加到CLASSPATH定义中,然后查看它是否有效。
you are gettig this error because servlet-api.jar file is not present in your path which you have written . 您收到此错误是因为您编写的路径中不存在servlet-api.jar文件。 Try to download servlet-api.jar file from this link http://www.java2s.com/Code/Jar/s/Downloadservletapijar.htm and extract the zip file in the download folder and then move servlet-api.jar to /var/lib/tomcat8/lib/ folder .
尝试从此链接http://www.java2s.com/Code/Jar/s/Downloadservletapijar.htm下载servlet-api.jar文件,然后将zip文件解压缩到下载文件夹中,然后将servlet-api.jar移至/ var / lib / tomcat8 / lib /文件夹。
And for complie java file first go to "src" folder in your project by terminal and write command.. 对于compli java文件,请首先通过终端转到项目中的“ src”文件夹并编写命令。
sudo javac -d ../classes/ *.java -cp /var/lib/tomcat8/lib/servlet-api.jar 须藤javac -d ../classes/ * .java -cp /var/lib/tomcat8/lib/servlet-api.jar
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.