Java Class Load loadClass(String name, ClassLoader loader)

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

Description

Load class or throw exception

License

Open Source License

Parameter

Parameter Description
loader a parameter

Declaration

public static Class<?> loadClass(String name, ClassLoader loader) 

Method Source Code

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

public class Main {
    /**// w ww.  j  a  v a 2 s .  c  o m
     * Load class or throw exception
     * @param loader
     */
    public static Class<?> loadClass(String name, ClassLoader loader) {
        try {
            return loader.loadClass(name);
        } catch (ClassNotFoundException e) {
            fatal("Class " + name + " not found.", e);
            return null;
        }
    }

    /** Print fatal error and exit. */
    public static <T> T fatal(String message, Exception e) {
        System.out.println(message);
        if (e != null && System.getProperty("stacktrace") != null)
            e.printStackTrace();
        System.exit(0);
        return (T) null;
    }
}

Related

  1. loadClass(String name)
  2. loadClass(String name)
  3. loadClass(String name)
  4. loadClass(String name, ClassLoader cl)
  5. loadClass(String name, ClassLoader ldr)
  6. loadClass(String theClassName, Class theReferrer)
  7. loadClass(T instance)
  8. loadClassByName(final String className, final ClassLoader loader)
  9. loadClassByName(String className)