File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes javac doesn't see the servlet.jar file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "javac doesn Watch "javac doesn New topic
Author

javac doesn't see the servlet.jar file

leo donahue
Ranch Hand

Joined: Apr 17, 2003
Posts: 327
I've searched through the ranch archives and the last posts related to this topic are dated in the year 2000 and haven't really answered my question.

I'm reading the Core Servlets book and trying to follow along setting up the classpath of all things. This should be simple, however, I'm not quite getting this development environment setup correctly.

I have the j2sdk 1.4.1.01 downloaded and installed here:
C:\j2sdk1.4.1_01

I have Tomcat 4.1 downloaded and installed here:
C:\Tomcat 4.1 (notice the space)

I have a servlet development directory here:
C:\ServletDev

My CLASSPATH environmental variable looks like this:
.;C:\ServletDevl;"C:\Tomcat 4.1\common\lib\servlet.jar"

My JAVA_HOME environmental varialbe looks like this:
C:\j2sdk1.4.1_01

My Path environmental variable looks like this:
.;C:\j2sdk1.4.1_01\bin; ...etc

I know I should have quotes around the path string in the CLASSPATH variable, but do they go around the whole path or just around the Tomcat 4.1 part?

The text has an example CLASSPATH variable that looks like this:
.;C:\ServletDev;install_dir\common\lib\servlet.jar

I've also read that I can copy the servlet.jar file to somewhere in the j2sdk, but I don't want to unless I have to.

I can open DOS and type from any directory and type:

java -version
javac -help

with no problems. I just can't compile a java source file that extends HttpServlet from any directory. I'm not going to use an IDE unless I have to.

I can also place a jsp file in the ROOT directory of Tomcat which contains a scriptlet <%= new java.util.Date() %> wrapped in html and get a result with no problems.

Any suggestions, or is anyone seeing something I'm forgeting?

Thanks everyone.


Thanks, leo
Shankar Narayana
Ranch Hand

Joined: Jan 08, 2003
Posts: 134

have a servlet development directory here:
C:\ServletDev

My CLASSPATH environmental variable looks like this:
.;C:\ServletDevl;"C:\Tomcat 4.1\common\lib\servlet.jar"



Hi Leo,

I think you have misspelled your directory in the classpath, it should be ServletDev instead of ServletDevl.


"Failure is not when you fall down; its only when you fail to get up again."
leo donahue
Ranch Hand

Joined: Apr 17, 2003
Posts: 327
You are correct! I did misspell that!

I made the change and I am still unable to compile a java file that extends HttpServlet.

My command line message says:

package javax.servlet does not exist.

I would expect this since my classpath variable is wrong somehow, but I don't see what else it could be.

Thank you,
Santosh Maskar
Ranch Hand

Joined: Jul 02, 2003
Posts: 226
Originally posted by leo donahue:
You are correct! I did misspell that!

I made the change and I am still unable to compile a java file that extends HttpServlet.


Check your JAVA_HOME AND CATELINA_HOME , are pointing to correct location
[ October 04, 2004: Message edited by: Santosh Maskar ]
leo donahue
Ranch Hand

Joined: Apr 17, 2003
Posts: 327
Thanks everyone, I have it now.

I forgot to add the CATALINA_HOME variable and then uncommented the path string to the servlet.jar in the CLASSPATH variable. I turned on servlet-mapping in the web.xml, stopped the server and restarted it and everything is working.

Thanks again.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: javac doesn't see the servlet.jar file