1 4 package com.tc.process; 5 6 import java.lang.reflect.Method ; 7 8 12 public class LinkedJavaProcessStarter { 13 14 public static void main(String args[], boolean useSystemClassLoader) throws Exception { 15 int pingPort = Integer.parseInt(args[0]); 16 String childClass = args[1]; 17 18 String [] realArgs = new String [args.length - 2]; 19 if (realArgs.length > 0) System.arraycopy(args, 2, realArgs, 0, realArgs.length); 20 21 LinkedJavaProcessPollingAgent.startClientWatchdogService(pingPort, childClass); 22 23 final Class mainClass; 24 if (useSystemClassLoader) { 25 mainClass = ClassLoader.getSystemClassLoader().loadClass(childClass); 26 } else { 27 mainClass = Class.forName(childClass); 28 } 29 30 Method mainMethod = mainClass.getMethod("main", new Class [] { String [].class }); 31 mainMethod.invoke(null, new Object [] { realArgs }); 32 33 } 34 35 public static void main(String [] args) throws Exception { 36 main(args, false); 37 } 38 39 } | Popular Tags |