List of usage examples for java.lang Class forName
@CallerSensitive public static Class<?> forName(String name, boolean initialize, ClassLoader loader) throws ClassNotFoundException
From source file:MyClass.java
public static void main(String[] args) { try {//from w w w . j ava2 s . c om String className = "MyClass"; boolean initialize = false; ClassLoader cLoader = Main.class.getClassLoader(); Class c = Class.forName(className, initialize, cLoader); className = "MyClass"; System.out.println("about to load"); // Will load and initialize the class c = Class.forName(className); } catch (ClassNotFoundException e) { System.out.println(e.getMessage()); } }