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 Trying to find javax, to compile Tomcat servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Trying to find javax, to compile Tomcat servlet" Watch "Trying to find javax, to compile Tomcat servlet" New topic
Author

Trying to find javax, to compile Tomcat servlet

william clemens
Greenhorn

Joined: May 23, 2001
Posts: 6
Where's that javax?
I am trying to compile a simple servlet with the statements

import javax.servlet.*
import javax.servlet.http.*
at the top. The compiler (running through TextPad) claims that the javax.servlet and javax.servlet.http packages do not exist. In running around this problem, I know there are a bunch of issues, but I can't figure it all out.
It appears that Tomcat is able to run a .class servlet, but the compiler is not able to compile one. What's different?
On a Windows 2000 system,
The CLASSPATH is:
C:\CoreJavaBook;.;.\lib;C:\jdk1.3;C:\jdk1.3\jakarta-tomcat3.2.1\lib;
The JAVA_HOME is:
c:\jdk1.3
The TOMCAT_HOME is:
c:\jdk1.3\jakarta-tomcat-3.2.1
When I start up Tomcat, it generates a message about all the .jar files it is including:
<message>
C:\jdk1.3\jakarta-tomcat-3.2.1\bin>startup
Including all jars in c:\jdk1.3\jakarta-tomcat-3.2.1\lib in your
CLASSPATH.
Using CLASSPATH:
c:\jdk1.3\jakarta-tomcat-3.2.1\classes;c:\jdk1.3\jakarta-tomcat
-3.2.1\lib\ant.jar;c:\jdk1.3\jakarta-tomcat-3.2.1\lib\jasper.jar;c:\jdk1.3\jakarta-tomcat-3.2.1\lib\jaxp.jar;c:\jdk1.3\jakarta-tomcat-3.2.1\lib\parser.
jar;c:\jdk1.3\jakarta-tomcat-3.2.1\lib\servlet.jar;c:\jdk1.3\jakarta-tomcat-3.2.1\lib\webserver.jar;C:\CoreJavaBook;.;.\lib;C:\jdk1.3;C:\jdk1.3\jakarta-tomcat3.2.1\lib;;c:\jdk1.3\l ib\tools.jar
</message>
I don't understand what "javax.servlet.http.*" is supposed to look like in the filesystem. "javax" seems to be a directory, with a "servlet" subdirectory, filled with .java files and an "http" directory. I don't see any .class files there.
How is the servlet.jar file related to all this? It is in several of the folders, but doesn't seem to be what the compiler is looking for. I don't see any files named javax, only folders.
Thanks for any and all insights!
Regards,
William C

Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
When you are running an application the system looks in your CLASSPATH for the stuff.
However you are compiling. In that case it looks for the stuff in your PATH statement. Check it out.


"JavaRanch, where the deer and the Certified play" - David O'Meara
william clemens
Greenhorn

Joined: May 23, 2001
Posts: 6
Originally posted by Cindy Glass:
When you are running an application the system looks in your CLASSPATH for the stuff.
However you are compiling. In that case it looks for the stuff in your PATH statement. Check it out.

Okay, I'm still not sure. Here's my Path statement:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\jdk1.3\bin;C:\jdk1.3\bin\javax;\jdk1.3\bin\javax\servlet;
The javax folder containing servlet folder containing the stuff is now in the bin path, but there is no change in the compiler messages. Packages javax.servlet and javax.servlet.http do not exist.
Thanks for the tipoff about the path, though.
Any more ideas?
Thanks,
William
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Two things.
The javax.servlet.* stuff is a package. You need to put the jar file that contains the package in the path and classpath, however you do NOT (should not) list the javax stuff.
You already have this
c:\jdk1.3\jakarta-tomcat-3.2.1\lib\servlet.jar in your classpath.
Try putting it in your path like this.
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\jdk1.3\bin;c:\jdk1.3\jakarta-tomcat-3.2.1\lib\servlet.jar
Then if this doesn't work I will move this post over to the servlet forum where they are more familiar with the TomCat setup.
william clemens
Greenhorn

Joined: May 23, 2001
Posts: 6
Hi again,
I made sure that it was set up like you suggested, but no dice. I'd be obliged if you could move the thread.
So, just to get this straight, when you import javax.servlet.* it will go look inside the servlet.jar file? I looked inside it with WinZip and it seems to contain the class files that I need.
Thanks for your help!
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Yeah, thats the way it works. I will move this now.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Trying to find javax, to compile Tomcat servlet