FileDocCategorySizeDatePackage
InvokeMain.javaAPI DocExample838Sun Feb 08 21:33:54 GMT 2004None

InvokeMain

public class InvokeMain extends Object
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 $

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.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);
		}
		//-