zoukankan      html  css  js  c++  java
  • jvm

    (1): null

    这个是根类加载器,它是由本地代码(c/c++)实现的,你根本拿不到他的引用,但是他实际存在,并且加载一些重要的类,它加载(%JAVA_HOME%jrelib),rt.jar(runtime)i18n.jar等,这些核心库中包含了Java的核心类.

    (2):扩展类加载器(ExtClassLoader),虽说能拿到,但是我们在实践中很少用到它,它主要加载扩展目录下的jar,

    %JRE_HOME%libext


    (3):应用类加载器(AppClassLoader), 它主要加载我们应用程序中的类,如Test,或者用到的第三方包,jdbc驱动包等。

    通过委托机制,应用扩展类加载器——ext-bootstarp(找不到)-ext(找不到类)-app(加载)

     

     

     

    启动类加载器(Bootstrap ClassLoader) 是C++ 写的 ,不能被java程序直接调用 输出为 null

    通过类加载器 加载properties http://www.cnblogs.com/1540340840qls/p/6184109.html

    public class PropertiesUtil {
        private static Properties p = null;
        static {
            InputStream in = null;
            try {// 通过自己的类找到
                in = PropertiesUtil.class.getClassLoader().getResourceAsStream("config.properties") ;
                p = new Properties();
                p.load(in);
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                if(in != null) {
                    try {
                        in.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    
        public static String getProperty(String key) {
            return p.getProperty(key);
        }
    }

    类加载器详细 https://www.ibm.com/developerworks/cn/java/j-lo-classloader/index.html

  • 相关阅读:
    adb 常用命令及操作
    服务器被黑检查命令
    linux总结
    mysql数据库常用操作
    Python字符串所有操作函数
    Python提示信息表示内容
    Linux基础命令wget(如何联网下载?)
    Linux基础命令sz
    Linux基础命令rz
    Linux基础命令find
  • 原文地址:https://www.cnblogs.com/mxz1994/p/7181949.html
Copyright © 2011-2022 走看看