Here you can find the source of invokeMain(ClassLoader classloader, String classname, String[] args)
private static void invokeMain(ClassLoader classloader, String classname, String[] args) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException
//package com.java2s; /*//from w w w. j av a 2s.c om * This software is distributed under the terms of the FSF * Gnu Lesser General Public License (see lgpl.txt). * * This program is distributed WITHOUT ANY WARRANTY. See the * GNU General Public License for more details. */ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; public class Main { private static void invokeMain(ClassLoader classloader, String classname, String[] args) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException { Class<?> invoked_class = classloader.loadClass(classname); Class<?>[] method_param_types = new Class[1]; method_param_types[0] = args.getClass(); Method main = invoked_class.getDeclaredMethod("main", method_param_types); Object[] method_params = new Object[1]; method_params[0] = args; main.invoke(null, method_params); } }