public class T003ClassLoaderScope {
public static void main(String[] args){
// 找到具体的jar包
String pathBoot = System.getProperty("sun.boot.class.path");
System.out.println(pathBoot.replaceAll(";", System.lineSeparator()));
}
}
public class T004ParentAndChild {
public static void main(String[] args){
// 该类的类加载器
System.out.println(T004ParentAndChild.class.getClassLoader().getParent());
}
}
public class T005LoadClassByHand {
public static void main(String[] args) throws ClassNotFoundException{
// 加载T003到T005中,和反射无区别。可以采用模板模式重写loadClass。
Class clazz = T005LoadClassByHand.class.getClassLoader().loadClass("javastudy.classloader.T003ClassLoaderScope");
System.out.println(clazz.getName());
}
}