如题
解决方案 »
- UDP测试
- *****100分求LOMBOZ (适合Eclipse3.2的),请看下面
- jar 包class动态加载问题 ,请高手指教 !
- apache 开源项目POI中HSSF(用来处理excel表的)使用中遇到的问题
- 如何从BufferedImage中获取图片大小(字节数)
- java的跨平台是怎么回事呢?能不能用编绎原理中的概念解释一下呢?
- 我是初学者,一个很简单的问题!
- 所有的java程序都要从main()开始吗?
- 马上加分!五分钟!
- 面板,表格和按钮布局问题,布局没弄明白.
- JAVA通过ODBC,连接到ACCESS上,哪位大哥,写个源码。谢谢
- 天啊!两个double类型的变量相加怎么会这样?
package test;import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class Main { private static boolean isInvoked = false; /**
* @param args
* @throws ClassNotFoundException
* @throws NoSuchMethodException
* @throws SecurityException
* @throws InvocationTargetException
* @throws IllegalAccessException
* @throws IllegalArgumentException
*/
public static void main(String[] args) throws
SecurityException,
NoSuchMethodException,
ClassNotFoundException,
IllegalArgumentException,
IllegalAccessException,
InvocationTargetException {
Method mainMethod = Class.forName("test.Main").getMethod("main", new Class[]{String[].class});
if (isInvoked) {
System.out.println("isInvoked");
} else {
isInvoked = true;
System.out.println("not isInvoked");
mainMethod.invoke(null, new Object[]{args});
}
}}
import java.lang.reflect.Method;/**
* Show loading a class and finding and calling its Main method.
*
* @author Ian F. Darwin, http://www.darwinsys.com/
* @version $Id: InvokeMain.java,v 1.3 2004/02/09 03:33:54 ian Exp $
*/
public class InvokeMain {
public static void main(String[] argv) {
//+
try {
// First, find the class.
Class c = Class.forName("InvokeMain"); // RECURSION
System.out.println(c); // Create the array of Argument Types
Class[] argTypes = { argv.getClass(), // array is Object!
}; // Now find the method
Method m = c.getMethod("main", argTypes);
System.out.println(m); // Create the actual argument array
Object passedArgv[] = { argv }; // Now invoke the method.
m.invoke(null, passedArgv); } catch (Exception e) {
System.err.println(e);
}
//-
}
}