When the JRE needs to load a new class, it consults following locations:
- bootstrap classes: the core API, rt.jar and i18n.jar
- installed extentions: all jars in lib/ext of JRE_HOME
- system classes: classes specified in the classpath
- download extensions: classes specified in the classpath header of installed extension jars, classpath jars, or previously downloaded download extensions.
1.2 has a delegation model for loading a class. Before loading a class with the current class loader, it is first delegated to the parent to check whether it can be loaded from there. For example, you could define your own package java.util and create a class Vector. Your class would be in the classpath and part of the system class loader, but this one delegates the request first to its parent, the bootstrap class loader which finds the class and loads it from there. This prevents a user from overriding security restrictions by replacing a class in the core API by an own version of the class.
You can create your own class loader by extending from java.lang.ClassLoader and you can specify a parent class loader. If you don’t specify the parent (null), then the system class loader will be its parent.