Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Still cant complile servlet after setting classpath

 
Max Vandenburg
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I dont get it!!!
Ok, im running the latest Apache Tomcat/5.5.17, and jdk1.5.0_06
I've also set up the TOMCAT_HOME and the JAVA_HOME to the following:

JAVA_HOME=C:\Program Files\Java\jdk1.5.0_06\bin
TOMCAT_HOME=C:\Program Files\Apache Software Foundation\Tomcat 5.5

and for the CLASSPATH
CLASSPATH=%CLASSPATH%;%TOMCAT_HOME%\common\lib\servlet-api.jar
the PATH is set to PATH=%PATH%;%JAVA_HOME%

when compiling my servlet by following the instruction in the Head First Servlet JSP (SelectBeer.java)

i get the same 6 error message package not found.
am i not setting the classpath correctly, but im pretty sure it is correct.
or do i also need to install the J2EE. can anyone help.

Thanks
 
Max Vandenburg
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i also tried to compile the SelectBeer.java using Eclipse (instead of using the command line) where i added the servlet-api.jar file to the libraries. this compiles fine and i managed to get the SelectBeer.class file --- which i then moved to:

%TOMCAT_HOME%\webapps\Beer-V1\WEB-INF\classes\com\example\web

then (did what it says on the book):
1. i restart tomcat
2. launch my browser and go to http://localhost:8088/Beer-V1/form.html
- this loads my "Beer Selection Page"
3. then the SUBMIT button is clicked... and i get err 404... which means that the servlet is not working...

can anyone spot where i make the obvious (not so obvious to me) mistake
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Firman Drage:

JAVA_HOME=C:\Program Files\Java\jdk1.5.0_06\bin
TOMCAT_HOME=C:\Program Files\Apache Software Foundation\Tomcat 5.5

and for the CLASSPATH
CLASSPATH=%CLASSPATH%;%TOMCAT_HOME%\common\lib\servlet-api.jar
the PATH is set to PATH=%PATH%;%JAVA_HOME%


The JAVA_HOME environment variable should not point to the 'bin' directory.
It should point to the root of your java installation (jdk1.5.0_6)

The PATH environment variable should point to the bin directory.
(If you're getting class not found problems during compilation then the JDK install probably took care of this for you and is allowing your OS to find javac in spite of the mistake in your PATH entry).

Have you tested your CLASSPATH variable?
Try typing:

It will print your CLASSPATH setting to the screen.
 
Max Vandenburg
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is what i got in the CLASSPATH
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're seeing the literal "%TOMCAT_HOME%" instead of the path to your tomcat install, then your TOMCAT_HOME environment variable is not set.

I'm going to move this to Java In General (Beginner).
A firm understanding classpaths and javac are prerequisites for efficient servlet development.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!