my dog learned polymorphism*
The moose likes Beginning Java and the fly likes do I need to specify every .jar in classpath ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "do I need to specify every .jar in classpath ?" Watch "do I need to specify every .jar in classpath ?" New topic
Author

do I need to specify every .jar in classpath ?

Frank Sikuluzu
Ranch Hand

Joined: Dec 16, 2003
Posts: 116
Think about the following case :

In a "lib/" directory there are ---

lib/p1/P1_C1.class, P1_C2.class
lib/p2/P2_C1.class, P2_C2.class

Now I do ---

cd lib/

jar cvf p1.jar p1
jar cvf p2.jar p2

so in "lib/" there are 2 jars p1.jar, p2.jar.

In my CLASSPATH can I simply add "lib/" or do I have to add "lib/p1.jar;lib/p2.jar", assuming both p1.jar and p2.jar are needed for the code to work ?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

You have to add each individual jar file.


[Jess in Action][AskingGoodQuestions]
Nigel Browne
Ranch Hand

Joined: May 15, 2001
Posts: 673
If you do not want to add each individual .jar file onto your CLASSPATH you can install them in the lib directory of your JRE and then they should be found automatically.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Originally posted by Nigel Browne:
If you do not want to add each individual .jar file onto your CLASSPATH you can install them in the lib directory of your JRE and then they should be found automatically.


The lib\ext directory. Yes, you can do that -- but often this just leads to more confusion, along the lines of "WHy does this work on my computer, but not my friend's computer?"
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
Originally posted by Ernest Friedman-Hill:


The lib\ext directory. Yes, you can do that -- but often this just leads to more confusion, along the lines of "WHy does this work on my computer, but not my friend's computer?"


or, "why does it not pick up the class from this new version" as /lib/ext takes presedence


42
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: do I need to specify every .jar in classpath ?
 
Similar Threads
add all subfolders to classpath
Regarding package usage
package vs directory
So difficult to use Layout managers!!!
Methods/Constructors Help