Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What's the class loading order ? 1

Status
Not open for further replies.

khho9

MIS
Mar 13, 2003
6
0
0
HK
Hi all ,

I am wondering if I have some local class, also, several set of the same name of classes packed as jar stored in various location of classpath. So what would the loading order of the classpath be ?
How could I verify which class are they loading ?

Thanks.

Perseus
 
Hi Perseus,

Classes are loaded in the order defined by the classpath. If you have duplicate classes in the classpath, the first one found will be used. I do not know that you can verify which classes are loading. Ideally you should not have duplicates of the same class location in your classpath.

Clearly, if you have two classes with the same name but in different packages, they can be distinguished by the package.

scrat
 
IIRC that the javac (compiler) will complain if two classes are found with the same class path (ie. package and name).
 
Use the verbose option to see what is being loaded.
 
Wow! Just tried out -verbose; That's one for the notebook.

scrat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top