The class loader is primarily responsible for loading the compiled. class file
1 Java ClassLoader categories
ClassLoader
|--bootstrap ClassLoader (startup class loader)
|--extension classloader (Extension class loader)
|--system ClassLoader (System class loader)
|--user Custom ClassLoader (user-defined class loader)
- Launch ClassLoader: Built in JVM boot, responsible for loading the Java Platform Core Library (Rt.jar)
- Extension ClassLoader: The user loads the $java_home/lib/ext directory, or the class library under the directory specified by Java.ext.dirs. general public class library files are placed in an extended directory and loaded with the extension class loader
- System ClassLoader: Loads the directories and jar files configured in the classpath, usually the Java classes we write are also loaded by the System class loader
- User-defined class loader: User-defined load rule loading
There is no too much description for the user-defined ClassLoader (you need to learn more)
2 How the ClassLoader works
When loading A. class file, first try to load with system ClassLoader, and when system ClassLoader receives the load command, it first attempts to load with the parent class loader. The parent class tries to load with the parent class of parent ... and so on until Bootstrap ClassLoader. And then go back to the back to the first class loader that can load this. class file. If none are found, the classnotfoundexception will be thrown.
The workflow of the class loader can be described as follows:
Java class Loader