Java Language Get Class given its (fully qualified) name


Example

Given a String containing the name of a class, it's Class object can be accessed using Class.forName:

Class clazz = null;
try {
    clazz = Class.forName("java.lang.Integer");
} catch (ClassNotFoundException ex) {
    throw new IllegalStateException(ex);
}
Java SE 1.2

It can be specified, if the class should be initialized (second parameter of forName) and which ClassLoader should be used (third parameter):

ClassLoader classLoader = ...
boolean initialize = ...
Class clazz = null;
try {
    clazz = Class.forName("java.lang.Integer", initialize, classLoader);
} catch (ClassNotFoundException ex) {
    throw new IllegalStateException(ex);
}