• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

My classpath doesn't stay upon reboot

 
Parka Teoh
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My CLASSPATH doesn't stay upon restarting my computer. As a result, if I don't set it again, I will have compilation errors in MSDOS.

Since I'm using servlets, I set my classpath as...
"set CLASSPATH=c:\j2sdk1.4.2_03\lib\servlet.jar". Is there something wrong?

I read in some book, the classpath was set to the JRE in Program Files/java

How can I make my classpath stay permanent?

Has it something to do with the environment variables in Control Panel>System?
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not try it, dude? You fixed your other problem yourself!

The answer is yes, if you create a new (User or System) environment variable called CLASSPATH via Control Panel and set it to your classpath it will persist when you reboot. You can also set it in autoexec.bat.

Jules
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But remember - Tomcat does not pay any attention to the environment CLASSPATH value. See the classloader how-to documentation installed with Tomcat.
Bill
 
Parka Teoh
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Julian Kennedy:
Why not try it, dude? You fixed your other problem yourself!

The answer is yes, if you create a new (User or System) environment variable called CLASSPATH via Control Panel and set it to your classpath it will persist when you reboot. You can also set it in autoexec.bat.

Jules


Am I doing it right here? It still doesn't work after I reboot. I'm also not good at the autoexec.bat

 
Parka Teoh
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by William Brogden:
But remember - Tomcat does not pay any attention to the environment CLASSPATH value. See the classloader how-to documentation installed with Tomcat.
Bill


Is this a problem caused by Tomcat? I mean, with the servlet packages, even without Tomcat, I should be able to compile my classes, right?
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Parka,

You appear to be doing it in the right place but it doesn't look like you're setting CLASSPATH correctly. If I just want to compile a servlet for Tomcat 5 in a Windows command window (MSDOS, if you like) then I'd set my classpath as follows:

That's because my Tomcat 5 installation comes with the Netbeans IDE. You should use the path to common\lib\servlet-api.jar in your installation (note you're missing .jar in your example - that won't help). You don't need any other files or directories (unless they're other JARs you're actually using). You don't need to move or copy the JAR files from where they're installed (it looks like you have done).

Bill's note applies when running your code in Tomcat. When running your JARs should typically be in one of the common lib directories or in the lib directory specific to the web app (i.e. under WEB-INF\lib). You don't need to worry about the servlets JAR in this respect however as it's set up at installation.

As you suspect, you can compile servlets independently of Tomcat or any other web container, provided that you have the JAR file.

Hope that helps.

Jules
 
Parka Teoh
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Julian Kennedy:
Hi Parka,

You appear to be doing it in the right place but it doesn't look like you're setting CLASSPATH correctly. If I just want to compile a servlet for Tomcat 5 in a Windows command window (MSDOS, if you like) then I'd set my classpath as follows:


.
.
.



Thanks!! It works now.
I can see how close yet how far I am.

My Tomcat 5 doesn't come with NetBeans. (maybe I just haven't found it)

 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glad it works. By the way, it's Netbeans that comes with Tomcat, not Tomcat that comes with Netbeans. [Edit: What I mean to say is that the Netbeans 3.6 installation includes Tomcat 5. A Tomcat installation would not include Netbeans] Don't forget to include the ".;" at the beginning of your CLASSPATH ("." is the current directory). You'll need it if you want to compile more than one source file in the same directory.

Jules
[ September 05, 2004: Message edited by: Julian Kennedy ]
 
Parka Teoh
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like this?

 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic