Solved

CLASSPATH of specifi JAR vs CLASSPATH of directory

Posted on 2001-07-19
8
399 Views
Last Modified: 2013-11-23
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.
0
Comment
Question by:ab11
8 Comments
 
LVL 3

Expert Comment

by:exorcist
ID: 6298108
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.
0
 
LVL 9

Expert Comment

by:Ovi
ID: 6298113
Nope
0
 

Expert Comment

by:LG_Goundalkar
ID: 6298130
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
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 3

Expert Comment

by:exorcist
ID: 6298163
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.
0
 
LVL 1

Expert Comment

by:tahir_naeem
ID: 6298207
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.
0
 

Author Comment

by:ab11
ID: 6298265
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 ?
0
 
LVL 3

Accepted Solution

by:
exorcist earned 100 total points
ID: 6298282
1. true
2. true
3. the jar is not included in your CLASSPATH (CLASSPATH is an environmental vairable), but you can use it as if it were in your CLASSPATH. So it's basically the same.
0
 

Author Comment

by:ab11
ID: 6299916
Thanks for help of all of you :)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question