Solved

CLASSPATH of specifi JAR vs CLASSPATH of directory

Posted on 2001-07-19
8
402 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

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.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
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…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

690 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