- The Java ClassLoader is a part of the Java Runtime Environment that used to dynamically loads Java classes into the JVM (Java Virtual Machine).
- A class loader is an object which are responsible for loading and executing classes during runtime dynamically to the JVM (Java Virtual Machine).
- Every Class object contains a reference to the ClassLoader that defined it.
- The Java run time system does not need to know about files and file systems because of classloaders.
There are three types of classloader in java.
- Bootstrap ClassLoader: Bootstrap ClassLoader is used to loads class from JRE/lib/rt.jar (Bootstrap Classloader is a Machine code which is used to kickstarts the operation when the JVM calls it. It is not a java class. Its job is to load the first pure Java ClassLoader. Bootstrap ClassLoader loads classes from the location rt.jar. Bootstrap ClassLoader doesn’t have any parent ClassLoaders. It is also called as the Primodial ClassLoader.)
- Extension ClassLoader: Extension ClassLoade is used to loads class from JRE/lib/ext directory (The extensions of core java classes are loaded from the respective JDK Extension library). This is a child class of Bootstrap ClassLoader.
- Application ClassLoader or System ClassLoader: Application ClassLoader is used to loads class from CLASSPATH, -classpath or -cp environment variable and this is a child class of Extension ClassLoader
There are three principles of functionality, as mention below. Principles of functionality are the set of rules or features on which a Java ClassLoader works.
- Delegation Model
- Visibility Principle
- Uniqueness Property
No comments:
Post a Comment