The System Class Loader is the default class loader used by the Java Runtime Environment (JRE). It loads class files from the file system and class path. In this article, we will take a deep dive into how the System Class Loader works and how to use it.
A class loader is a program that loads class files from a file system or network and makes them available to the Java Virtual Machine (JVM). Class loaders are used to load classes at run time.
There are three types of class loaders in Java:
The Bootstrap ClassLoader loads the core Java classes, such as java.lang.Object, from the rt.jar file. The Extension ClassLoader loads classes from the ext folder. The System ClassLoader loads classes from the classpath.
The System Class Loader loads class files from the file system and class path. The file system is the file system of the local machine. The class path is a list of locations that the System Class Loader searches for class files.
The System Class Loader uses a three-step process to load class files:
The System Class Loader can load class files from the file system, the class path, or the network.
The System Class Loader can be used to load class files from the file system, the class path, or the network.
To load class files from the file system, you can use the java.lang.ClassLoader.getSystemResourceAsStream() method. This method returns an InputStream that can be used to read the class file from the file system.
To load class files from the class path, you can use the java.lang.ClassLoader.getSystemResourceAsStream() method. This method returns an InputStream that can be used to read the class file from the class path.
To load class files from the network, you can use the java.lang.ClassLoader.getSystemResourceAsStream() method. This method returns an InputStream that can be used to read the class file from the network.
In this article, we have taken a deep dive into Java's System Class Loader. We have seen what a class loader is and how the System Class Loader works. We have also seen how to use the System Class Loader to load class files from the file system, the class path, or the network.