This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
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
MV
Max Vandenburg
Ranch Hand
Joined: Mar 09, 2006
Posts: 51
posted
0
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:
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
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.
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.
Max Vandenburg
Ranch Hand
Joined: Mar 09, 2006
Posts: 51
posted
0
after system restart:
so now i know that the classpath is set correcly... i also re-check the PATH to make sure it doesnt say %JAVA_HOME% , rather the actual path where the java is installed.
then i tried to compile the servlet again
Mike Noel
Ranch Hand
Joined: Dec 15, 2005
Posts: 108
posted
0
Aren't those packages/classes in the j2ee.jar file? It doesn't look like you're including that.
No those are correct... because i set the classpath to include the servlet-api.jar, and they also works ... erm after i re-deploy the class file to the server side.
Thanks, :roll:
Rusty Shackleford
Ranch Hand
Joined: Jan 03, 2006
Posts: 490
posted
0
I had a hard time getting Tomcat set up properly also. Then i used this preconfigured setup, from the Author of Core servlets and JSP. Was compiling and running servlets 5 minutes later. Might be worth a try.
"Computer science is no more about computers than astronomy is about telescopes" - Edsger Dijkstra
You are using a colon ( instead of a semi-colon (;) to separate the classpath entries. That's wrong on Windows. Use a semi-colon instead. [ July 13, 2006: Message edited by: Jesper Young ]
thanks for pointing that out... after setting the CLASSPATH environment variable to include the pathXXXX\servlet-jar.api - i no longer needed the -classpath option in the javaccommand
so the cmd used was: javac -d classes src/com/example/web/BeerSelect.java
but yes, Jesper Young, you are right to point out about the colon ( vs. semicolon ( thing.