Link to home
Start Free TrialLog in
Avatar of ab11
ab11

asked on

CLASSPATH of specifi JAR vs CLASSPATH of directory

Hi !

Suppose I have some JAR file, whcih should be in my CLASSPATH. Is there any difference when I set my CLASSPATH as c:\MYJava\SomeJar.jar or c:\MYJava.

I understand, that with the "directory" way all my JARs at this path would be in CLASSPATH. Is there any other differences ?

Thanks.
Avatar of exorcist
exorcist

No, that's wrong. Jar files are only accessible if you have the specific jar file in your classpath. Just pointing the classpath at the directory where the jar file is is not enough.
Nope
Taht is Wrong.
You have to specify the .jar or .zip file name in the Classpath environment variable setting.
If you specify the directory the classes in the directory will be considered.

Thanks.
LGG
I have to correct my post a little.

There is one exception to it. Jar files put into the directory [javadir]/jre/lib/ext/ are all accessible just as if they were in your CLASSPATH.

So instead of changing your CLASSPATH, you can also copy the jar files in this directory.
The directory '[javadir]/jre/lib/ext/' is an exception to this rule. Sun declares that this directory should be used for standard extensions (or extensions that might be considered as standard). In all other cases you have to specify the fully qualified path of the .jar file not the parent directory. In other such example is also seen in WAR (web archive) files where you place all library jar files under <app_root>/WEB-INF/lib, they are automatically included in CLASSPATH of the web application.
Avatar of ab11

ASKER

So, if I summirize:

1. I have to settle the full CLASSPATH for the JAR, including the JAR name.
2. For my standard *.class files I specify the CLASSPATH, which contains the derictory
3. I can put my JAR file in '[javadir]/jre/lib/ext/ and it will be automatically inckuded in my CLASSPATH.

Is this correct ?
ASKER CERTIFIED SOLUTION
Avatar of exorcist
exorcist

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ab11

ASKER

Thanks for help of all of you :)