This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes order of jar files in classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "order of jar files in classpath" Watch "order of jar files in classpath" New topic
Author

order of jar files in classpath

ben oliver
Ranch Hand

Joined: Mar 28, 2006
Posts: 374
I was following an instruction to add some .jar files into classpath. After that I found I could not compile properly, then I realized that I added all the jar files but not in the order it specified. So I changed the order of the jar files (still the same jar files) and it compiled fine.

Does the sequence of jar files you add to classpath matter and why ?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19655
    
  18

This probably has something to do with classes that are in more than 1 JAR file. The system class loader checks the JAR files / folders on the class path in order of declaration. If one JAR has version A of a class and another JAR has version B of that same class, then you will use version A if the first JAR is first and version B if the second is first.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
Consider Paul's rocket mass heater.
 
subject: order of jar files in classpath
 
Similar Threads
Debug Error with JPA/Hibernate
dynamic classpath
Problem using PDFBox to extract text from PDF documents
jdic and outlook
Building JAR