public class Test
{
public static void main(String args[]) throws Exception
{
new Test(args[0], args[1]);
}
public Test (String className, String methodName) throws Exception
{
Class c = Class.forName(className);
Method m = c.getMethod(methodName, null);
m.invoke(this, null);
}
}
File Name: MyClass1.java
-----------------------------
public class MyClass1
{
public static void testMethod ()
{
System.out.println("My Name is MyClass1");
}
}
File Name: MyClass2.java
----------------------------
public class MyClass2
{
public static void testMethod ()
{
System.out.println("My Name is MyClass2");
}
}