I know this is a common error, but bear with me. I've pursued the CLASSPATH problem and I don't think that is the issue. I'm getting an error like this.
./src/process.java:2: package javax.servlet does not exist
import javax.servlet.*;
I installed Tomcat and the Java SDK, and I know that Tomcat is supposed to supply the servlet API. But what file is it exactly looking for?
I have the following settings: JAVA_HOME=/usr/java/jdk1.6.0_16 CLASSPATH=/usr/share/java;/usr/share/java/tomcat6
The base directory for tomcat: /usr/share/tomcat6 In this directory, /usr/share/tomcat6/lib is simply a symlink to /usr/share/java/tomcat6
tomcat6-servlet-2.5-api-6.0.18.jar is in /usr/share/java/tomcat6, is there anything else I need to be telling javac about so it will use this library? Is there another library that I need?
For background, I'm trying to get a hello world servlet running. The code is as follows:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class process extends HttpServlet {
public void doGet( HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("Hello World");
}
}
When I compile this with javac I get the following errors (amongst others of which this is the root cause):
./src/process.java:2: package javax.servlet does not exist
import javax.servlet.*;
^
./src/process.java:3: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
I tried specifying the classpath on the command line as well with the -cp option, but I ended up with the same results.