File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Java in General
Bookmark "ClassPath class loader" Watch "ClassPath class loader" New topic

ClassPath class loader

arunseege paramashivappa
Ranch Hand

Joined: Nov 02, 2010
Posts: 33

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.


Stephan van Hulst

Joined: Sep 20, 2010
Posts: 4594

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.

The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
I agree. Here's the link:
subject: ClassPath class loader
It's not a secret anymore!