What is a class loader ?

The Java Class Loader is the class responsible for finding and loading class files at run time. Creating your own ClassLoader lets you customize the JVM in useful and interesting ways, allowing you to completely redefine how class files are brought into the system. The following part is taken from JavaDoc

Class ClassLoader java.lang.Object  
public abstract class ClassLoader extends Object

A class loader is an object that is responsible for loading classes. The class ClassLoader is an abstract class. Given the name of a class, a class loader should attempt to locate or generate data that constitutes a definition for the class. A typical strategy is to transform the name into a file name and then read a "class file" of that name from a file system. The Java Classloader is a part of the Java Runtime Environment (JRE) that dynamically loads Java classes into the Java Virtual Machine. Usually classes are only loaded on demand.

Types of Classloaders When the JVM is started, three class loaders are used:
•    Bootstrap class loader (jre/lib)
•    Extensions class loader (jre/lib/ext)
•    System class loader (classpath)

  1. The bootstrap class loader loads the core Java libraries located in the <JAVA_HOME>/jre/lib directory. This class loader, which is part of the core JVM, is written in native code.
  2. The extensions class loader loads the code in the extensions directories <JAVA_HOME>/jre/lib/ext or any other directory specified by the java.ext.dirs system property. It is implemented by the sun.misc.Launcher$ExtClassLoader class.
  3. The system class loader loads code found on java.class.path, which maps to the system CLASSPATH variable. This is implemented by the sun.misc.Launcher$AppClassLoader class.

core java 12


Explore Tutu'rself