wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Path/Classpath Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Path/Classpath Problem" Watch "Path/Classpath Problem" New topic
Author

Path/Classpath Problem

William A White
Ranch Hand

Joined: Jul 01, 2004
Posts: 35
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?
Mike Firkser
Ranch Hand

Joined: Oct 21, 2003
Posts: 247

Have you tried an or an just to make sure you didn't do a typo when setting the variables on your machine?


Mike Firkser
Rutgers '84
Jeff Pavlocak
Greenhorn

Joined: Apr 26, 2004
Posts: 16
Are you using the DOS command line or some GUI tool to compile your code?

If it's a GUI tool which one, and is it the same tool at home as at work?

Jeff
Tony Jackson
Ranch Hand

Joined: Feb 23, 2001
Posts: 45
William,

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.

Tony
William A White
Ranch Hand

Joined: Jul 01, 2004
Posts: 35
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Path/Classpath Problem
 
Similar Threads
Using a directory inside of a JAR file
crontab
my JarLoader breaks when replacing the jar file
ECLIPSE, ANT and generating WAR files...
Resource loading from system file path VS classpath