List of usage examples for java.net URLClassLoader loadClass
public final Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
From source file:MainClass.java
public static void main(String args[]) { String name = "http://urlWithClassName"; try {/* ww w . j a va 2 s. c om*/ if (!name.endsWith(".class")) { System.err.println("That doesn't look like a byte code file!"); return; } URL u = new URL(name); URLClassLoader ucl = new URLClassLoader(u); // parse out the name of the class from the URL String s = u.getFile(); String classname = s.substring(s.lastIndexOf('/'), s.lastIndexOf(".class")); Class AppletClass = ucl.loadClass(classname, true); Applet apl = (Applet) AppletClass.newInstance(); JFrame f = new JFrame(); f.setSize(200, 200); f.add("Center", apl); apl.init(); apl.start(); f.setVisible(true); } catch (Exception e) { System.err.println(e); } }