Returns the context class loader. - Java Reflection

Java examples for Reflection:Class Loader

Description

Returns the context class loader.

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        System.out.println(getLoader());
    }/*  w ww . jav a2 s . co  m*/

    /**
     * Returns the context class loader.
     * 
     * @return the context class loader
     */
    public static ClassLoader getLoader() {
        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        if (loader == null) {
            loader = ClassLoader.class.getClassLoader();
        }
        return loader;
    }
}

Related Tutorials