Code example for URLClassLoader

Methods: loadClass

0
URL[] urls = new URL[] { new URL(args[0]) };
        //System.err.println("before: " + render(args)); 
        args = getArgs(args);
        //System.err.println("after: " + render(args)); 
        URLClassLoader cl = new URLClassLoader(urls);
        Class c = cl.loadClass("$installer$.org.aspectj.Main"); // todo: dependency on class name
        Method ms = c.getMethod("main", new Class[]{String[].class});
        ms.invoke(null, new Object[] { args });
    } 
    public static final String render(String[] args) {
        StringBuffer sb = new StringBuffer();
        sb.append("[");
        for (int i = 0; i < args.length; i++) {
            if (0 < i) sb.append(", ");
            sb.append("" + args[i]);
        } 
        sb.append("]");
        return sb.toString();
    }