package test; import java.io.File; /** * Tests MultiClassLoader, URLClassLoader and FileClassLoader. * If no command options are * entered then the url is used. Otherwise local file * loading is used, which allows testing locally before * server deployment. * * Note - Still cannot get to work: *** * String root = "http://localhost/file:///C|jp/test/store/"; * or * String root = "file:///C|jp/test/store/"; * Does anyone have suggestions??? * * @author Jack Harich - 8/18/97 */ public class TestLoader { //---------- Initialization ------------------------------ public static void main(String[] args) { new TestLoader(args); } public TestLoader(String[] args) { // Init the preferred class loader MultiClassLoader loader = null; if (args.length == 0) { String root = "http://www.mindspring.com/~happyjac/"; loader = new URLClassLoader(root); } else { loader = new FileClassLoader("store" + File.separator); } loader.setClassNameReplacementChar('_'); // A series of tests: Class testClass = null; try { testClass = loader.loadClass("Hello"); } catch(Exception ex) { print("Load failed"); ex.printStackTrace(); return; } print("Loaded class " + testClass.getName() ); try { Runnable hello = (Runnable)testClass.newInstance(); hello.run(); } catch(Exception ex) { print("Failed to instantiate"); ex.printStackTrace(); } } //---------- Private Methods ----------------------------- //--- Std private static void print(String text) { System.out.println(text); } } // End class