Here you can find the source of invokeMain(Class> fooClass)
public static void invokeMain(Class<?> fooClass) throws Exception
//package com.java2s; //License from project: Apache License import java.lang.reflect.Method; public class Main { public static void invokeMain(Class<?> fooClass) throws Exception { System.out.println();/* www.ja v a 2 s. c o m*/ System.out.println(fooClass.getName() + " loaded by " + fooClass.getClassLoader()); Method main = fooClass.getMethod("main", String[].class); System.out.println("Get method: " + main); Object ret = main.invoke(null, new Object[] { new String[] { "a", "b", "c" } }); System.out.printf("Return is %s\n", ret); } }