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(ClassLoader classLoader, Class clazz, String postfix)
load Class
String className = clazz.getName();
try {
    return Class.forName(className.concat(postfix), false, classLoader);
} catch (ClassNotFoundException cnfe) {
return null;
ClassloadClass(ClassLoader classLoader, String className)
load Class
try {
    return classLoader.loadClass(className);
} catch (NoClassDefFoundError e) {
    throw new RuntimeException(e);
} catch (ClassNotFoundException e) {
    throw new RuntimeException(e);
ClassloadClass(ClassLoader classLoader, String className)
Load class with given className over given classLoader and suppress ClassNotFoundException .
try {
    return load(classLoader, className);
} catch (ClassNotFoundException e) {
    return null;
ClassloadClass(ClassLoader classLoader, String fullyQualifiedClassName)
Load a class.
try {
    return classLoader.loadClass(fullyQualifiedClassName);
} catch (ClassNotFoundException e) {
    throw new RuntimeException(e);
ClassloadClass(ClassLoader loader, String className)
load Class
try {
    return loader.loadClass(className);
} catch (ClassNotFoundException e) {
    return loadClass(className);
ClassloadClass(ClassLoader loader, String className, String errorMessage)
load Class
Class clazz;
try {
    clazz = loader.loadClass(className);
} catch (ClassNotFoundException e) {
    throw new ClassNotFoundException(errorMessage, e);
return clazz;
ClassloadClass(final ClassLoader cl, final String cname)
load Class
try {
    return cl.loadClass(cname);
} catch (Exception x) {
return null;
ClassloadClass(final ClassLoader classLoader, final String classname)
Loads a class with a given name.
Class<?> classToLoad = null;
if (classLoader == null) {
    classToLoad = Class.forName(classname);
} else {
    classToLoad = classLoader.loadClass(classname);
return classToLoad;
ClassloadClass(final String className)
Load class, if found on the classpath.
try {
    return getThreadClassLoader().loadClass(className);
} catch (final Exception ignored) {
} catch (final NoClassDefFoundError ignored) {
return null;
ClassloadClass(final String className)
Attempts to create a class from a String.
try {
    return (Class<T>) Class.forName(className);
} catch (final ClassNotFoundException e) {
    throw new IllegalArgumentException(className + " class not found.");