You never need to set the CLASSPATH variable, ever.
When you compile or run (javac command and java command respectively) the default classpath is the current directory. Do nothing and everything will probably work. Set the CLASSPATH and it will probaby break. Why? A common error is to leave out the current directory, ".", hence, a endless parade of CLASSPATH questions from those starting to use Java.
Now, if you have additional class folders and jars (jars are treated like folders containing classes in a sense) you supply them as follows.
javac -classpath ... java -classpath ...
Sometimes what you need to run is more than you need to compile, so they aren't always the same. Most intro programs need nothing at all. They use the current directory plus the built-in Java classes.
P.S. The ranch intro contains no information about the default classpath, it should.
Patrick van Zandbeek
Joined: Aug 17, 2005
taken from reading through the javaranch faq under setting the classpath in windows. Not very verbose about default classpath but the dot is definitely there...
Joined: Sep 19, 2004
That's good but I was referring to the lack of mention of what the default classpath is. I'm sure people follow that advice and add the dot and probably foo.jar along with it IMO it should state that the default value is the current directory. [ August 23, 2005: Message edited by: Rick O'Shay ]