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, ClassLoader classLoader)
load Class
try {
    return classLoader.loadClass(className);
} catch (Exception e) {
    throw new IllegalArgumentException("loadClass(" + className + ")  with ex:", e);
ClassloadClass(String clazz, ClassLoader cl)
Load class from class name, swallowing possible ClassNotFoundException.
cl = cl == null ? Thread.currentThread().getContextClassLoader() : cl;
try {
    return cl.loadClass(clazz);
} catch (ClassNotFoundException e) {
    return null;
ClassloadClass(String fqcn, Class... classes)
Loads the class via the optionally specified classes in the order of their specification, and if not found, via the context class loader of the current thread, and if not found, from the caller class loader as the last resort.
return loadClass(fqcn, true, classes);
ClassloadClass(String h, String prefix)
Load a named class.
if (h.indexOf(".") < 0)
    h = prefix + h;
try {
    Class handleClass = Class.forName(h);
    return handleClass;
} catch (Exception e) {
return null;
...
ClassloadClass(String inClassName)
load Class
try {
    return (Class<T>) ClassLoader.getSystemClassLoader().loadClass(inClassName);
} catch (final Exception e) {
return (Class<T>) Thread.currentThread().getContextClassLoader().loadClass(inClassName);
CloadClass(String name)
load Class
return (C) ClassLoader.getSystemClassLoader().loadClass(name).newInstance();
ClassloadClass(String name)
Load class by name.
switch (name) {
case "int":
    return int.class;
case "short":
    return short.class;
case "char":
    return char.class;
case "byte":
...
ClassloadClass(String name)
load Class
try {
    return Thread.currentThread().getContextClassLoader().loadClass(name);
} catch (ClassNotFoundException e) {
    e.printStackTrace();
    return null;
ClassloadClass(String name)
Load the class with the given name
try {
    return Class.forName(name);
} catch (ClassNotFoundException e) {
    throw e;
ClassloadClass(String name)
Thanks to Max Andersen at JBOSS and Scott Stanchfield
try {
    ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
    if (!useDirectClassLoading && contextClassLoader != null) {
        return contextClassLoader.loadClass(name);
    return Class.forName(name);
} catch (Exception e) {
    return Class.forName(name);
...