File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes ClassPath class loader Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "ClassPath class loader" Watch "ClassPath class loader" New topic
Author

ClassPath class loader

arunseege paramashivappa
Greenhorn

Joined: Nov 02, 2010
Posts: 25

Hi All,

Can anyone please give info. on classpath class loader.My understanding as of now is

whenever we say

Java xyz.

JVM will search for it in classpath and load it into JVM.


But my confusion is system class loader and classpath class loader are one and the same?.

And also when an instance of JVM is created which are the class loaders will executed.

Please give me supporting links to understand class loading clearly and better.

Thanks-Arun


Thanks-Arun
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3366
    
    9
Hi Arunseege, welcome to CodeRanch!

No, the classpath loader and the system loader aren't the same.

Now, it's been a while since I delved into this subject, but I believe that when you start the JVM, it will always initialize the system loader. It's responsible for loading those few classes that are necessary for the JVM itself to run, and for it to be able to delegate the rest of the classes to other class loaders. This is only speculation on my end, but I think it's responsible for loading classes such as Object, Class, ClassLoader, String, arrays, etc. I believe the system class loader is more or less "hardcoded" into the JVM's executable. I'm not actually sure of this last part, because I think you can even specify a custom loader that's responsible for these classes.

When the system class loader is done, the JVM creates an instance of whatever default loader is in the configuration files. This would be the Classpath loader by default. You can also create your own custom loader and have it initialize that instead.

When a class' name is referenced, the JVM will get the class loader that loaded the class that references it, and ask it to retrieve its Class instance. The loader will first ask its "superior" loader (usually the Classpath loader) for the Class, which in turn will ask its own superior (the system loader). If the system loader can't find the Class, the classpath loader will try to find it, and if it can't find it either, the loader below that goes to find it.

You can probably get more detailed and correct info if you go through the ClassLoader docs, the Virtual Machine documentation, and if you just google around.
 
 
subject: ClassPath class loader
 
Similar Threads
Correct location of language properties bundle files
Java Class Loaders - basics
simple search v/s classpath search
Classloader and JVM
Please help me understand some concepts about classloader