i hv just downloaded the binary distribution of tomcat6. the server is running fine.
the /srv/tomcat/lib has servlet-api.jar. i suppose this path is to be set as classpath. i did so. but servlet compilation still gives errors ( for javax.servlet package). plz help me with this.
btw i used this command for setting classpath environment variable
$ CLASSPATH=/srv/tomcat/lib/servlet-api.jar
$ export CLASSPATH
Can you post the errors here?
javac test.java
test.java:2: package javax.servlet does not exist
import javax.servlet.;
^
test.java:3: package javax.servlet.http does not exist
import javax.servlet.http.;
^
test.java:5: cannot find symbol
symbol: class HttpServlet
public class test extends HttpServlet {
^
test.java:7: cannot find symbol
symbol : class HttpServletRequest
location: class test
public void doGet(HttpServletRequest request, HttpServletResponse response)
^
test.java:7: cannot find symbol
symbol : class HttpServletResponse
location: class test
public void doGet(HttpServletRequest request, HttpServletResponse response)
^
test.java:8: cannot find symbol
symbol : class ServletException
location: class test
throws IOException, ServletException
^
6 errors
Are you sure you are not making any spelling mistake while setting the CLASSPATH?
Just verify:
echo $CLASSPATH
ls -l `echo $CLASSPATH`
yes the echo command gives the correct output. but i think the classpath variable is not persistent. coz i close the Konsole and again give the echo command it doesnt give any output. then i have 2 set the classpath again. but the compilation error always occurs
If you want to make it persistent, edit the file .profile and put the commands towards the end of that file.
export CLASSPATH=/srv/tomcat/lib/servlet-api.jar