Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   * See the file LICENSE for redistribution information.
   * Copyright (c) 2002, 2013 Oracle and/or its affiliates.  All rights reserved.
Used as the main class for the manifest of the je.jar file, and so it is executed when running: java -jar je.jar. The first argument must be the final part of the class name of a utility in the package, e.g., DbDump. All following parameters are passed to the main method of the utility and are processed as usual. Apart from the package, this class is ambivalent about the name of the utility specified; the only requirement is that it must be a public static class and must contain a public static main method.
 public class JarMain {
     private static final String USAGE = "usage: java <utility> [options...]";
     /* Use a HashMap to allow the utilities to live in multiple packages. */
     private static HashMap<StringStringutilPrefixMap =
         new HashMap<StringString>();
     /* Map each utility name to its package. */
     static {
         /* The utilities in directory com/sleepycat/je/util. */
         /* The utilities in directory com/sleepycat/je/rep/util. */
         /* The utilities in directory com/sleepycat/je/rep/utilint. */
     /* List all the available utilities. */
     private static String availableUtilities() {
         StringBuilder sbuf = new StringBuilder();
         for (String util : .keySet()) {
         return sbuf.toString();
     public static void main(String[] args) {
         try {
             if (args.length < 1) {
                 usage("Missing utility name");
             String utilPrefix = .get(args[0]);
             if (utilPrefix == null) {
                 ..println("Available utilities are: ");
                 usage("No such utility");
             Class<?> cls = Class.forName(utilPrefix + args[0]);
             Method mainMethod = cls.getMethod
                 ("main"new Class[] { String[].class });
             String[] mainArgs = new String[args.length - 1];
             System.arraycopy(args, 1, mainArgs, 0, mainArgs.length);
             mainMethod.invoke(nullnew Object[] { mainArgs });
         } catch (InvocationTargetException ITE) {
            if (ITE.getCause() != null) {
            } else {
                ..println("Problem invoking main method:");
        } catch (Throwable e) {
    private static void usage(String msg) {
New to GrepCode? Check out our FAQ X