Load a class given its name.
import java.net.MalformedURLException;
import java.net.URL;
public class ClassUtils {
public static Class loadClass(String className) throws ClassNotFoundException {
return getClassLoader().loadClass(className);
}
public static URL getResource(String resource) throws MalformedURLException {
return getClassLoader().getResource(resource);
}
public static ClassLoader getClassLoader() {
return Thread.currentThread().getContextClassLoader();
}
}
Home
Java Book
Runnable examples
Java Book
Runnable examples
Reflection Class:
- Class modifier: public, abstract or final
- Class simple name plus package name
- Create new instance
- Class reflection, all methods, constructors, parameters, interfaces
- Get super class name
- Get the class By way of .class
- Get unqualified class Name
- Is Type Compatible
- Is Primitive type
- Load a class given its name.