public static void main(String[] args) { // System.out.println(System.getProperty("sun.boot.class.path")); // System.out.println(System.getProperty("java.ext.dirs")); // System.out.println(System.getProperty("java.class.path")); System.out.println("BootstrapClassLoader 的加载路径: "); URL[] urls = sun.misc.Launcher.getBootstrapClassPath().getURLs(); for(URL url : urls) System.out.println(url); System.out.println("----------------------------"); //取得扩展类加载器 URLClassLoader extClassLoader = (URLClassLoader)ClassLoader.getSystemClassLoader().getParent(); System.out.println(extClassLoader); System.out.println("扩展类加载器 的加载路径: "); urls = extClassLoader.getURLs(); for(URL url : urls) System.out.println(url); System.out.println("----------------------------"); //取得应用(系统)类加载器 URLClassLoader appClassLoader = (URLClassLoader)ClassLoader.getSystemClassLoader(); System.out.println(appClassLoader); System.out.println("应用(系统)类加载器 的加载路径: "); urls = appClassLoader.getURLs(); for(URL url : urls) System.out.println(url); System.out.println("----------------------------"); }
BootstrapClassLoader 的加载路径: file:/C:/Program%20Files/Java/jdk1.8.0_91/jre/lib/resources.jar file:/C:/Program%20Files/Java/jdk1.8.0_91/jre/lib/rt.jar file:/C:/Program%20Files/Java/jdk1.8.0_91/jre/lib/sunrsasign.jar file:/C:/Program%20Files/Java/jdk1.8.0_91/jre/lib/jsse.jar file:/C:/Program%20Files/Java/jdk1.8.0_91/jre/lib/jce.jar file:/C:/Program%20Files/Java/jdk1.8.0_91/jre/lib/charsets.jar file:/C:/Program%20Files/Java/jdk1.8.0_91/jre/lib/jfr.jar file:/C:/Program%20Files/Java/jdk1.8.0_91/jre/classes ---------------------------- sun.misc.Launcher$ExtClassLoader@5e481248 扩展类加载器 的加载路径: file:/C:/Program%20Files/Java/jdk1.8.0_91/jre/lib/ext/access-bridge-64.jar file:/C:/Program%20Files/Java/jdk1.8.0_91/jre/lib/ext/cldrdata.jar file:/C:/Program%20Files/Java/jdk1.8.0_91/jre/lib/ext/dnsns.jar file:/C:/Program%20Files/Java/jdk1.8.0_91/jre/lib/ext/jaccess.jar file:/C:/Program%20Files/Java/jdk1.8.0_91/jre/lib/ext/jfxrt.jar file:/C:/Program%20Files/Java/jdk1.8.0_91/jre/lib/ext/localedata.jar file:/C:/Program%20Files/Java/jdk1.8.0_91/jre/lib/ext/nashorn.jar file:/C:/Program%20Files/Java/jdk1.8.0_91/jre/lib/ext/sunec.jar file:/C:/Program%20Files/Java/jdk1.8.0_91/jre/lib/ext/sunjce_provider.jar file:/C:/Program%20Files/Java/jdk1.8.0_91/jre/lib/ext/sunmscapi.jar file:/C:/Program%20Files/Java/jdk1.8.0_91/jre/lib/ext/sunpkcs11.jar file:/C:/Program%20Files/Java/jdk1.8.0_91/jre/lib/ext/zipfs.jar ---------------------------- sun.misc.Launcher$AppClassLoader@1d44bcfa
应用(系统)类加载器 的加载路径:
这里就打印的jar是系统的classpath路径:System.getProperty("java.class.path");
即WEB-INF/classes/里面的class文件 和 项目引用的jar