01: //***** Remote class loading 02: 03: import java.net.MalformedURLException; 04: import java.net.URL; 05: import java.net.URLClassLoader; 06: public class SimpleClassLoader { 07: public static void main(String[ ] args) { 08: try { 09: // Hard code the URL to test. 10: // Directories must end with '/' 11: String url = "http://condor.depaul.edu/dmumaugh/JDP/test/"; 12: 13: // Create an array of URLS to search. 14: URL[ ] urls = { new URL(url) }; 15: 16: // Construct a loader to search the URLs. 17: URLClassLoader ucl = new URLClassLoader(urls); 18: 19: // Load the class and instantiate it. 20: Class class_A = ucl.loadClass("A"); 21: Object object_A = class_A.newInstance(); 22: System.out.println("Class name: " + class_A); 23: System.out.println("Object: " + object_A); 24: } 25: catch(MalformedURLException e) { 26: System.err.println(e); 27: } 28: catch(ClassNotFoundException e) { 29: System.err.println(e); 30: } 31: catch(IllegalAccessException e) { 32: System.err.println(e); 33: } 34: catch(InstantiationException e) { 35: System.err.println(e); 36: } 37: } 38: }