Methods Summary |
---|
static java.lang.Object[] | getArgs(java.lang.String[] args)
String passArgs[] = new String[args.length - numArgs];
for (int i = numArgs; i < args.length; i++)
passArgs[i - numArgs] = args[i];
Object wrapArgs[] = new Object[1];
wrapArgs[0] = passArgs;
return wrapArgs;
|
void | invokeMain(java.lang.Class clazz)
Class argList[] = new Class[] { String[].class };
Method mainMethod = null;
try {
mainMethod = clazz.getMethod("main", argList);
} catch (NoSuchMethodException nsme) {
System.out.println("No main method in " + clazz.getName());
System.exit(-1);
}
try {
mainMethod.invoke(null, args);
} catch (Exception e) {
Throwable t;
if (e instanceof InvocationTargetException)
t = ((InvocationTargetException) e)
.getTargetException();
else t = e;
System.out.println("Procedure exited with exception " + t);
t.printStackTrace();
}
|
public static void | main(java.lang.String[] args)
try {
if (args.length < 1) {
System.err.println("usage: JavaRunner classfile");
System.exit(-1);
}
ThreadGroup tg = new ThreadGroup("JavaRunner Threadgroup");
Thread t = new Thread(tg,
new JavaRunner(args[0], getArgs(args)));
t.start();
try {
t.join();
} catch (InterruptedException ie) {
System.out.println("Thread was interrupted");
}
} catch (Exception e) {
e.printStackTrace();
}
|
public void | run()
Class target = null;
try {
target = Class.forName(className);
invokeMain(target);
} catch (ClassNotFoundException cnfe) {
System.out.println("Can't load " + className);
}
|