1. jvm classloader 分
bootstrap classloader
system classloader
extention classloader
package com.jason.jvm;
import java.net.URL;
public class JvmClassLoaderDemo {
/**
* bootstrap classloader
*/
public void bootstrap(){
URL[] urls=sun.misc.Launcher.getBootstrapClassPath().getURLs();
for (int i = 0; i < urls.length; i++) {
System.out.println(urls[i].toExternalForm());
}
}
/**
* extention classloader
*/
public void extention(){
System.out.println(System.getProperty("java.ext.dirs"));
ClassLoader extensionClassloader=ClassLoader.getSystemClassLoader().getParent();
System.out.println("the parent of extension classloader : "+extensionClassloader.getParent());
}
/**
* system classloader
*/
public void system(){
System.out.println(System.getProperty("java.class.path"));
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
JvmClassLoaderDemo a = new JvmClassLoaderDemo();
System.out.println("**********bootstrap begin************");
a.bootstrap();
System.out.println("**********bootstrap end************");
System.out.println("**********extention begin************");
a.extention();
System.out.println("**********extention end************");
System.out.println("**********system begin************");
a.system();
System.out.println("**********system end************");
}
}