Java Class Load classForName(String className)

Here you can find the source of classForName(String className)

Description

class For Name

License

Apache License

Declaration

public static Class<?> classForName(String className) 

Method Source Code

//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License");

public class Main {
    public static Class<?> classForName(String className) {
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        try {/*from  w ww .j  a v a 2s .c  o m*/
            return Class.forName(className, true, cl);
        } catch (Throwable ex) {
            try {
                Class.forName(className, true, cl);
            } catch (Exception ex2) {

            }
            throw new RuntimeException("Failed to load class: " + className + "; " + ex.getMessage(), ex);
        }
    }

    public static <T> Class<T> classForName(String className, Class<T> ifacecls) {
        return (Class<T>) classForName(className);
    }
}

Related

  1. classForName(String className)
  2. classForName(String className)
  3. classForName(String className)
  4. classForName(String className)
  5. classForName(String className)
  6. ClassForName(String className)
  7. classForName(String className, Class caller)
  8. classForName(String className, Class superClass)
  9. classForName(String className, ClassLoader classLoader)