Javac error when compiling Servlet libraries

I am using ubuntu and I set my paths as follows:

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

I thought I would put the servlet libraries in the compilation path, but I still get these compilation errors:

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

Any ideas how to fix this or what am I doing wrong? Usually Java libraries work fine.

+1
source share
1 answer

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

  • Specify each jar file separately in CLASSPATH:

    export CLASSPATH=/usr/local/tomcat/lib/servlet-impl.jar:/path/to/another.jar
    
  • Since you are using Java 6, you can use wildcards (to include all banks in the directory):

    export CLASSPATH=/usr/local/tomcat/lib/*
    
+7
source

All Articles