It's not a secret anymore!
The moose likes Beginning Java and the fly likes Setting CLASSPATH Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Setting CLASSPATH" Watch "Setting CLASSPATH" New topic


Mark Mokris
Ranch Hand

Joined: May 08, 2002
Posts: 61
Why do need to always set the CLASSPATH even through I am just working with one class in one directory, and that class is in my current directory?
Steve Luke

Joined: Jan 28, 2003
Posts: 4181

Are you always setting it using the
java -classpath ... method? If so you are only
setting it for a particular run of the JVM. You
can set you system's CLASSPATH variable so you
don't have to do this all the time.
For Windows 98(maybe 95 and ME too):
Start Menu>Run...>type in msconfig
Click on the autoexec.bat tab
Editthe text SET CLASSPATH=C:\PROGRA~1\JAVA\J2RE1.4.1_01\lib\rt.jar (or something close
at the end of this, put a ; (semicolon) and either type in the full path to where the .class is located OR type in a . (period)

For Windows 2000/XP:
Start Menu>Settings>Control Panel
Advanced Tab
Environment Variables
Find the CLASSPATH variable and edit as above
DOn't know about any other OS

I agree. Here's the link:
subject: Setting CLASSPATH
It's not a secret anymore!