try {
System.out.println("With the URLConnection's class loader");
URL u = new URL("http://metalab.unc.edu/javafaq/");
URLConnection uc = u.openConnection();
Object o = Class.forName("com.macfaq.net.www.content.text.tab",
true, u.getClass().getClassLoader());
System.out.println(o);
System.out.println(o.getClass());
System.out.println(o.getClass().getClassLoader());
}
catch (Exception e) {
e.printStackTrace();
}
try {
System.out.println("With a null class loader");
Object o = Class.forName("com.macfaq.net.www.content.text.tab",
true, null);
System.out.println(o);
System.out.println(o.getClass());
System.out.println(o.getClass().getClassLoader());
}
catch (Exception e) {
e.printStackTrace();
}
try {
System.out.println("With the single argument forName method");
Object o = Class.forName("com.macfaq.net.www.content.text.tab");
System.out.println(o);
System.out.println(o.getClass());
System.out.println(o.getClass().getClassLoader());
}
catch (Exception e) {
System.out.println(e);
e.printStackTrace();
}