The class loader locates and reads the *.class files needed to execute the Java program and loads the bytecodes into memory. To safeguard a secure execution, it can assign different portions (namespaces) of memory to locally versus remotely obtained classes. Classes are typically assembled into libraries that are stored physically in JAR (Java Archive) files. The libraries may have been written by the user or obtained externally. In order to locate the classes, the class loader will first find the corresponding libraries and then load the classes as they are needed by the program (called on demand loading). The class loader basically has three subcomponents:
➤ Bootstrap class loader
The bootstrap class loader loads the core Java libraries located in <JAVA_HOME>
➤ Extensions class loader
The extensions class loader loads the classes from the extensions directory <JAVA_HOME>
➤ System class loader
The system class loader loads the code from the locations specified in the CLASSPATH environment variable, which is defined by the operating system. The latter provides the path to all physical directories where the system class loader can look for Java files.