OK... I *think* I understand the path and classpath variables. I'm not a beginning Java programmer, but this problem is pretty basic.
My home machine requires that any resources I use in my code be fully qualified. So I write code at work that loads a JAR just by using the name of the JAR and it works fine. At home, I have to modify the code so it loads it with 'c:/resources/some.jar', for example. I get the same problem with XML files, images, sounds, everything.
It's a winXP box, brand-new clean install with the latest SDK. What could possibly be causing this problem?
Do you have the current directory (.) in your classpath? Maybe at work you do but at home it is missing?
That probably would not account for all your problems, but it is worth checking.
PATH: used by the operating system to find executables (particularly javac.exe and java.exe, which are the java compiler and the java runtime, respecively)
CLASSPATH: used by the Java VM to find classes. Classes that are part of standard Java (such as java.lang.System and java.util.Vector) don't have to be added to the CLASSPATH, as Java VM inherently knows how to find them). But if you have code in a class that calls another class (creates an object, or calls a method) then you need to have that other class in your CLASSPATH.
One thing about classpath that seems to confuse some people is that while you can add directories to your classpath, you also can add jar files. Since a jar file is an archive of directories, it is considered a directory, so you must put the jar file in your classpath, not just the directory where the jar file is located.
That means if you have 10 jar files in the same directory you must add all ten of them to your classpath.
William A White
Joined: Jul 01, 2004
Well, I use NetBeans 3.6 both at home and work. I do have the current directory in my PATH here at home, though I think that is not necessary anyways.