本帖最后由 王桂丽 于 2012-9-26 17:37 编辑
import java.lang.reflect.*;
import java.io.*;
class ManiTest
{
//为什么编译不出错,运行出错
//Exception in thread "main" java.lang.NoClassDefFoundError: MainTest
public static void main(String[] args) throws Exception
{
//ArgumentsTest.main(new String[]{"111","222","333"});
//System.out.println("Hello World!");
String name=args[0];
Method mainmethod=Class.forName(name).getMethod("main",String[].class);
mainmethod.invoke(null,new String[]{"111","222","333"});
}
}
class ArgumentsTest
{
public static void main(String[] args)
{
for(String arg:args)
System.out.println(arg);
}
}
|