wood burning stoves 2.0*
The moose likes Servlets and the fly likes setup question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "setup question" Watch "setup question" New topic
Author

setup question

Charles Cayman
Greenhorn

Joined: Jul 02, 2002
Posts: 8
Hi,
I'm beginning to study servlets and all those stuff... I have my jdk131 installed,
and my tomcat up and running...
However, when I try to compile my first servlets using javac, it does not
see where the servlet libraries are. After some searching and head-scratching,
I found a servlet.jar in one of Tomcat's subdirectory. I know this is related,
but I couldn't figure out what to do... I have been changing a lot like changing
the CLASSPATH, PATH, etc.; but nothing seems to do the trick.
How do I make this work?
Thanks a lot in advance!!!
[ July 02, 2002: Message edited by: Charles Cayman ]
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

Just put the servlet.jar in your global CLASSPATH
If you are using windows 98/ME - you should add e.g. C:\tomcat\lib\servlet.jar to the CLASSPATH in autoexec.bat, and restarted your PC?
If using windows NT/2000/XP - then you should add e.g. C:\tomcat\lib\servlet.jar to the CLASSPATH in your 'Environment Variables'.
You should now be able to type javac SomeServlet.java without any errors.
Sometimes it is a god idea to add a .(dot) to the CLASSPATH as well.
/Rene


Regards, Rene Larsen
Dropbox Invite
Charles Cayman
Greenhorn

Joined: Jul 02, 2002
Posts: 8
Hi, thanks for the reply.
I'm using Windows 2000 Pro. I went to the System Properties and looked at the Environment Variables, but only to find out that I don't have the privileges to edit them. I tried editing the CLASSPATH using a batch file. The CLASSPATH contains the new path, but it still does not work... Maybe, I need to edit the one in the System properties? I'll try to ask our administrator later or tomorrow to edit the environment variables...
Thanks!
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

You can also just use the option -classpath when you compile the code.
e.g. javac -classpath .;C:\tomcat\lib\servlet.jar TestServlet.java
/Rene
[ July 03, 2002: Message edited by: Rene Larsen ]
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Put the servlet.jar file in your
jdk1.3\jre\lib\ext\ directory.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Charles Cayman
Greenhorn

Joined: Jul 02, 2002
Posts: 8
Hi,
Thanks everybody... It's working now...
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: setup question
 
Similar Threads
Servlet filter question
Restrict the URL Access in Servlets 2.2
want to stop executing servlet in websphere4.0:URGENT
How does java bean event work in JSP?
cant i change LAF at runtime?