1 8 9 package com.sleepycat.je.utilint; 10 11 import java.lang.reflect.Method ; 12 13 24 public class JarMain { 25 26 private static final String USAGE = "usage: java <utility> [options...]"; 27 private static final String PREFIX = "com.sleepycat.je.util."; 28 29 public static void main(String [] args) { 30 try { 31 if (args.length < 1) { 32 usage("Missing utility name"); 33 } 34 Class cls = Class.forName(PREFIX + args[0]); 35 36 Method mainMethod = cls.getMethod 37 ("main", new Class [] { String [].class }); 38 39 String [] mainArgs = new String [args.length - 1]; 40 System.arraycopy(args, 1, mainArgs, 0, mainArgs.length); 41 42 mainMethod.invoke(null, new Object [] { mainArgs }); 43 } catch (Throwable e) { 44 usage(e.toString()); 45 } 46 } 47 48 private static void usage(String msg) { 49 System.err.println(msg); 50 System.err.println(USAGE); 51 System.exit(-1); 52 } 53 } 54 | Popular Tags |