Here you can find the source of invokeMain(String... args)
public static void invokeMain(String... args)
//package com.java2s; /**//from w w w .j a v a 2 s .c o m * Copyright (c) 2014-2015 by Wen Yu. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Any modifications to this file must keep this entire header intact. */ import java.util.Arrays; import java.lang.reflect.Method; public class Main { public static void invokeMain(String... args) { try { Class<?> c = Class.forName(args[0]); Class<String[]> argTypes = String[].class; Method main = c.getDeclaredMethod("main", argTypes); Object mainArgs = Arrays.copyOfRange(args, 1, args.length); System.out.format("invoking %s.main()%n", c.getName()); main.invoke(null, mainArgs); } catch (Exception ex) { ex.printStackTrace(); } } }