Home » Java programming language

Java ClassLoader getSystemClassLoader() method with example

ClassLoader Class getSystemClassLoader() method: Here, we are going to learn about the getSystemClassLoader() method of ClassLoader Class with its syntax and example.
Submitted by Preeti Jain, on November 26, 2019

ClassLoader Class getSystemClassLoader() method

  • getSystemClassLoader() method is available in java.lang package.
  • getSystemClassLoader() method is used to find the System class loader for delegation and this will be the default delegation parent for the new instance of the ClassLoader.
  • getSystemClassLoader() method is a static method, it is accessible with the class name and if we try to access the method with the class object then we will not get any error.
  • getSystemClassLoader() method may throw an exception at the time of checking security constraints.
    • SecurityException: In this exception, its checkPermission() method does not allow access to the system classloader when the security manager exists.
    • IllegalStateException: In this exception when called recursively during the construction of the class loader given by the property "java.system.class.loader".


    static ClassLoader getSystemClassLoader();


  • It does not accept any parameter.

Return value:

The return type of this method is ClassLoader, it returns the system class loader of ClassLoader type.


// Java program to demonstrate the example 
// of ClassLoader getSystemClassLoader() method of ClassLoader 

public class GetSystemClassLoader {
    public static void main(String[] args) throws Exception {
        // It returns the Class object attached with the given 
        // classname
        Class cl = Class.forName("GetSystemClassLoader");

        // It returns the ClassLoader object attached with the given 
        // classname
        ClassLoader loader = cl.getClassLoader();

        // Display Loader Class

        // It returns the SystemClassLoader object attached with the 
        // given classname
        loader = loader.getSystemClassLoader();

        // Display SystemClassLoader Class


class jdk.internal.loader.ClassLoaders$AppClassLoader
class jdk.internal.loader.ClassLoaders$AppClassLoader


Comments and Discussions



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© some rights reserved.