Javac erroring out when compiling Servlet libraries

我怕爱的太早我们不能终老 提交于 2019-12-13 19:46:59

问题


I am using ubuntu and I have set my paths to be the following:

JAVA_HOME=/usr/local/jdk1.6.0_24
export CLASSPATH=/usr/local/tomcat/lib
export JAVA_HOME

I thought that would put the servlet libraries in the compile path, but I am still getting compile errors like this:

package javax.servlet does not exist
    [javac] import javax.servlet.ServletException;

Any ideas how to fix this or what I am doing wrong? The general Java libraries seem to be working fine.


回答1:


With jar files, simply specifying a directory containing jar files will not work. You have two options:

  1. Specify each jar file individually on the CLASSPATH:

    export CLASSPATH=/usr/local/tomcat/lib/servlet-impl.jar:/path/to/another.jar
    
  2. Since you're using Java 6, you should be able to use wildcards (to include all jars in a directory):

    export CLASSPATH=/usr/local/tomcat/lib/*
    


来源:https://stackoverflow.com/questions/5625589/javac-erroring-out-when-compiling-servlet-libraries

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!