The Java Classloader is a part of the
Each Java class must be loaded by a class loader.
JRE
that dynamically loads Java classes into the JVM
. Usually classes are only loaded on demand. The Java run time system does not need to know about files and file systems because of classloaders
.Each Java class must be loaded by a class loader.
When the
JVM
is started, three class loaders are used:
(1) Bootstrap class loader:It loads the core Java libraries located in the
<JAVA_HOME>/jre/lib
directory. Bootstrap
class loade part of the core JVM and written in native code.
(2) Extensions class loader:It loads the code in the extensions directories (
<JAVA_HOME>/jre/lib/ext
, or any other directory specified by the java.ext.dirs
system property)
(3)System class loader:It loads code found on
java.class.path
, which maps to the CLASSPATH.
Whenever a new JVM is started the bootstrap classloader is responsible to load key Java classes (from
java.lang
package) and other runtime classes to the memory first. The bootstrap classloader is a parent of all other classloaders. Consequently, it is the only one without a parent.
Next comes the extension classloader. It has the bootstrap classloader as parent and is responsible for loading classes from all
.jar
files kept in the java.ext.dirs
path–these are available regardless of the JVM’s classpath.
The third and most important classloader from a developer’s perspective is the system classpath classloader, which is an immediate child of the extension classloader. It loads classes from directories and jar files specified by the
CLASSPATH
environment variable, java.class.path
system property or -classpath
command line option.
No comments:
Post a Comment