Java Utililty Methods Class Load

List of utility methods to do Class Load

Description

The list of methods to do Class Load are organized into topic(s).

Method

ClassloadClass(String className)
load Class
Class<?> clazz = null;
if (className == null) {
    return null;
try {
    return Class.forName(className);
} catch (ClassNotFoundException e) {
ClassLoader ctxClassLoader = Thread.currentThread().getContextClassLoader();
if (ctxClassLoader != null) {
    try {
        clazz = ctxClassLoader.loadClass(className);
    } catch (ClassNotFoundException e) {
return clazz;
ClassloadClass(String className)
Loads a class by its fully qualified class name.
return loadClass(className, null);
ClassloadClass(String className)
load Class
return loadClass(className, true);
ClassloadClass(String className)
load Class
Class classImpl = null;
try {
    classImpl = Class.forName(className);
} catch (ClassNotFoundException cnfe) {
return classImpl;
ClassloadClass(String className)
load Class
return loadClass(Thread.currentThread().getContextClassLoader(), className);
ClassloadClass(String className)
Loads the class with the specified name
try {
    return Class.forName(className);
} catch (ClassNotFoundException e) {
    throw new RuntimeException("Error loading class " + className, e);
} catch (NoClassDefFoundError e) {
    throw new RuntimeException("Error loading class " + className, e);
ClassloadClass(String className)
load Class
ClassLoader cl = Thread.currentThread().getContextClassLoader();
return loadClass(className, cl);
ObjectloadClass(String className)
load Class
Class<?> c = Class.forName(className);
return c.newInstance();
ClassloadClass(String className, boolean isInitialized)
load Class
Class<?> clazz;
try {
    clazz = Class.forName(className, isInitialized, getClassLoader());
} catch (ClassNotFoundException cnfe) {
    cnfe.printStackTrace();
    throw new RuntimeException(cnfe);
return clazz;
...
ClassloadClass(String className, Class callingClass)
Loads the given class using the current Thread's context class loader first otherwise use the class loader which loaded this class.
ClassLoader loader = Thread.currentThread().getContextClassLoader();
if (loader == null) {
    return getClassLoader(callingClass).loadClass(className);
} else {
    return loader.loadClass(className);