aspose file tools*
The moose likes Servlets and the fly likes permanently set classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "permanently set classpath" Watch "permanently set classpath" New topic
Author

permanently set classpath

Simon Xu
Ranch Hand

Joined: Aug 16, 2000
Posts: 235
hi,
When I start Tomcat, it shows the classpath which I set before installation of Tomcat. I added new classpath to the autoexec file, but it wont showup in the tomcat startup window. I should set it in commmand line. How could I solve this problem?
Thanks
Simon
Phil Hanna
Ranch Hand

Joined: Apr 05, 2001
Posts: 118
You start Tomcat from a .bat file, correct? To see how the classpath is being set, the best place to look is the .bat file. You shouldn't have any trouble figuring out what each line does. Startup.bat calls tomcat.bat, which builds the classpath a piece at a time. You can tell by reading tomcat.bat that it does not use the classpath environment variable. Look at the line containing "Using CLASSPATH:". If that doesn't contain all the classes you want, add a line to tomcat.bat that does.


Phil Hanna<BR>Sun Certified Programmer for the Java 2 Platform<BR>Author of :<BR><A HREF="http://www.amazon.com/exec/obidos/ASIN/0072127686/electricporkchop/107-3548162-1137317" TARGET=_blank rel="nofollow">JSP: The Complete Reference</A><BR><A HREF="http://www.amazon.com/exec/obidos/ASIN/0072124253/electricporkchop/107-3548162-1137317" TARGET=_blank rel="nofollow">Instant Java Servlets</A>
Simon Xu
Ranch Hand

Joined: Aug 16, 2000
Posts: 235
hi, Phil,
Thanks so much for your help.
But my case is little different. I have a direct application using applet-java (socket communication) which loads and executes dynamically the classes in one folder (myFolder) after user selects the class name. it works well. Now I shift to applet-servlet (still using socket commu) and implement a Servlet which loads at startup time during Tomcat which listens for the client input. But now problem happens. When I select the class name in client side (HTML-applet), the server (servlet) gives me the classNoFoundException. My first though was the classpath problem. I try to set in command line, it still does not not.
Could you find the problem?
By the way, the tomcat.bat file refers to .jar file. But my all classes are stored in C:\myFloder. How to set it in tomcat.bat ?
Please help, Thanks
Simon
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
Simon,
We needn't edit tomcat.bat file to include our own classpath. Tomcat takes care of that. It checks if something already in %CLASSPATH% enviornment var. If so, it appends its own classes to the old one. Else creates a new CLASSPATH. I just copied the whole tomcat.bat for your reference. Please check. Also when you start tomcat check what is echoed in dos window for "Using CLASSPATH...... lines. See if it contains your c:\MyFolder. If not you edit c:\autoexec.bat file and add this as (almost) first classpath next to "c:\." so that c:\MyFolder will get higher priority. A sample autoexec.bat could be

Everytime you make changes in classpath inside autoexec.bat file first stop tomcat server and run this new c:\autoexec.bat file at dos prompt and finally start tomcat again so that the new classpath will come into effect.
<DOS> c:\autoexec.bat
regds
maha anna


[This message has been edited by maha anna (edited April 17, 2001).]
Simon Xu
Ranch Hand

Joined: Aug 16, 2000
Posts: 235
hi, Maha,
Thank your for your help. The priority point solves the problem.
Thank Phil also for your expla. JavaRach is indeed freindly place to learn!!
Simon
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: permanently set classpath