Solved

CLASSPATH of specifi JAR vs CLASSPATH of directory

Posted on 2001-07-19
8
401 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to get all the API from website? 11 156
Java string replace 11 73
Glassfish admin console not working 1 81
Java: anonymous class 4 51
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

742 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