集册 Java实例教程 返回上下文类加载器。

返回上下文类加载器。

欢马劈雪     最近更新时间:2020-01-02 10:19:05

391
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
返回上下文类加载器。
// from N o w J a v a . c o m - 时代Java


//package com.nowjava;


public class Main {

    public static void main(String[] argv) throws Exception {

        System.out.println(getLoader());

    }


    /**

     * 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;

    }
    /**
    nowjava.com - 时代Java 提供 
    **/

}