ClassLoader: loadClass(String name) : ClassLoader « java.lang « Java by API






ClassLoader: loadClass(String name)

 
import java.io.File;
import java.net.URL;
import java.net.URLClassLoader;

public class Main {
  public static void main(String[] argv) throws Exception {
    File file = new File("c:\\");

    URL url = file.toURI().toURL(); 
    URL[] urls = new URL[] { url };

    ClassLoader cl = new URLClassLoader(urls);

    Class cls = cl.loadClass("com.mycompany.MyClass");
  }
}

   
  








Related examples in the same category

1.extends ClassLoader
2.ClassLoader: getSystemClassLoader()
3.ClassLoader: setDefaultAssertionStatus(boolean enabled)