Example & Tutorial understanding programming in easy ways.

What is Dynamic Class Loading using java Reflection Api ?

Dynamic Class Loading
This java example shows how to load a class dynamically. It obtains a ClassLoader and makes a call to its loadClass() method.

class Test {

}

public class ClassLoading {

public static void main(String[] args) {

ClassLoader cl = ClassLoading.class.getClassLoader();

try {

Class c = cl.loadClass("Test");

System.out.println("c.getName() = " + c.getName());

} catch (Exception e) {

System.out.println("Exception: " + e.toString());

}

}

Read More →