Java Class Load loadClass(String name)

Here you can find the source of loadClass(String name)

Description

Thanks to Max Andersen at JBOSS and Scott Stanchfield

License

Open Source License

Declaration

public static Class loadClass(String name) throws ClassNotFoundException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    private static boolean useDirectClassLoading = false;

    /** Thanks to Max Andersen at JBOSS and Scott Stanchfield */
    public static Class loadClass(String name) throws ClassNotFoundException {
        try {/* ww w .ja v  a  2s  . com*/
            ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
            if (!useDirectClassLoading && contextClassLoader != null) {
                return contextClassLoader.loadClass(name);
            }
            return Class.forName(name);
        } catch (Exception e) {
            return Class.forName(name);
        }
    }
}

Related

  1. loadClass(String inClassName)
  2. loadClass(String name)
  3. loadClass(String name)
  4. loadClass(String name)
  5. loadClass(String name)
  6. loadClass(String name)
  7. loadClass(String name)
  8. loadClass(String name, ClassLoader cl)
  9. loadClass(String name, ClassLoader ldr)