Example usage for java.lang Exception getMessage

List of usage examples for java.lang Exception getMessage

Introduction

In this page you can find the example usage for java.lang Exception getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:edu.msu.cme.rdp.classifier.train.validation.distance.PairwiseSeqDistance.java

/**
* This program does the pairwise alignment between each pair of sequences, 
* reports a summary of the average distances and the stdev at each rank.
* @param args//from  w  w w  .j a  va  2 s . co  m
* @throws Exception 
*/
public static void main(String[] args) throws Exception {

    String trainseqFile = null;
    String taxFile = null;
    PrintStream outStream = null;
    AlignmentMode mode = AlignmentMode.overlap;
    boolean show_alignment = false;

    try {
        CommandLine line = new PosixParser().parse(options, args);

        if (line.hasOption("show_alignment")) {
            show_alignment = true;
        }
        if (line.hasOption("alignment-mode")) {
            String m = line.getOptionValue("alignment-mode").toLowerCase();
            mode = AlignmentMode.valueOf(m);

        }

        if (args.length != 3) {
            throw new Exception("wrong arguments");
        }
        args = line.getArgs();
        trainseqFile = args[0];
        taxFile = args[1];
        outStream = new PrintStream(new File(args[2]));
    } catch (Exception e) {
        System.err.println("Command Error: " + e.getMessage());
        new HelpFormatter().printHelp(80, " [options] trainseqFile taxonFile outFile", "", options, "");
        return;
    }

    PairwiseSeqDistance theObj = new PairwiseSeqDistance(trainseqFile, taxFile, mode, show_alignment);

    theObj.printSummary(outStream);
}

From source file:net.mybox.mybox.ClientSetup.java

/**
 * Handle command line arguments/*from  w w w .  j  av  a2 s . c  o  m*/
 * @param args
 */
public static void main(String[] args) {

    Options options = new Options();
    options.addOption("a", "apphome", true, "application home directory");
    options.addOption("h", "help", false, "show help screen");
    options.addOption("V", "version", false, "print the Mybox version");

    CommandLineParser line = new GnuParser();
    CommandLine cmd = null;

    String configDir = Client.defaultConfigDir;

    try {
        cmd = line.parse(options, args);
    } catch (Exception exp) {
        System.err.println(exp.getMessage());
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(Client.class.getName(), options);
        return;
    }

    if (cmd.hasOption("h")) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(Client.class.getName(), options);
        return;
    }

    if (cmd.hasOption("V")) {
        Client.printMessage("version " + Common.appVersion);
        return;
    }

    if (cmd.hasOption("a")) {
        String appHomeDir = cmd.getOptionValue("a");
        try {
            Common.updatePaths(appHomeDir);
        } catch (FileNotFoundException e) {
            Client.printErrorExit(e.getMessage());
        }

        Client.updatePaths();
    }

    ClientSetup setup = new ClientSetup();

}

From source file:com.github.r351574nc3.amex.assignment2.App.java

public static void main(final String... args) {
    if (args.length < 1) {
        printUsage();/*from ww  w  .  ja  va2s  . c  o  m*/
        System.exit(0);
    }

    final Options options = new Options();
    options.addOption(OptionBuilder.withArgName("test").hasArg(true).isRequired(true)
            .withDescription("Path for ARFF test data").create("t"));
    options.addOption(OptionBuilder.withArgName("output").hasArg(true).isRequired(true)
            .withDescription("Path for ARFF output").create("o"));
    options.addOption(OptionBuilder.withArgName("input").hasArg(true).isRequired(true)
            .withDescription("Path for ARFF input").create("i"));

    final CommandLineParser parser = new BasicParser();
    CommandLine cmd = null;
    try {
        cmd = parser.parse(options, args);
    } catch (Exception e) {
        System.out.println(e.getMessage());
        printUsage();
        System.exit(0);
    }

    final String outputName = cmd.getOptionValue("o");
    final String inputName = cmd.getOptionValue("i");
    final String testName = cmd.getOptionValue("t");

    final App app = new App();
    try {
        if (args.length > 0) {
            app.setTrained(app.load(testName));
            app.setTest(app.load(testName));
        }
    } catch (Exception e) {
        error("There was an exception loading training and test datasets: %s", e.getMessage());
    }

    try {
        app.train();
        app.test();
    } catch (Exception e) {
        error("There was an exception testing the model: %s", e.getMessage());
    }

    try {
        app.predict(inputName, outputName);
    } catch (Exception e) {
        error("There was an exception predicting MPG: %s", e.getMessage());
        e.printStackTrace();
    }

    System.exit(0);

}

From source file:com.genentech.chemistry.openEye.apps.SDFTopologicalIndexer.java

/**
 * @param args//w ww. j a  v a  2 s  .c om
 */
public static void main(String... args) throws IOException { // create command line Options object
    Options options = new Options();
    Option opt = new Option(OPT_INFILE, true,
            "input file oe-supported Use .sdf|.smi to specify the file type.");
    opt.setRequired(true);
    opt.setArgName("fn");
    options.addOption(opt);

    opt = new Option(OPT_OUTFILE, true, "output file oe-supported. Use .sdf|.smi to specify the file type.");
    opt.setRequired(true);
    opt.setArgName("fn");
    options.addOption(opt);

    CommandLineParser parser = new PosixParser();
    CommandLine cmd = null;
    try {
        cmd = parser.parse(options, args);
    } catch (Exception e) {
        System.err.println(e.getMessage());
        exitWithHelp(options);
    }
    args = cmd.getArgs();

    if (cmd.hasOption("d")) {
        System.err.println("Start debugger and press return:");
        new BufferedReader(new InputStreamReader(System.in)).readLine();
    }

    if (args.length == 0) {
        System.err.println("Specify at least one index type");
        exitWithHelp(options);
    }

    String inFile = cmd.getOptionValue(OPT_INFILE);
    String outFile = cmd.getOptionValue(OPT_OUTFILE);
    Set<String> selectedIndexes = new HashSet<String>(args.length);
    if (args.length == 1 && "all".equalsIgnoreCase(args[0]))
        selectedIndexes = AVAILIndexes;
    else
        selectedIndexes.addAll(Arrays.asList(args));

    if (!AVAILIndexes.containsAll(selectedIndexes)) {
        selectedIndexes.removeAll(AVAILIndexes);
        StringBuilder err = new StringBuilder("Unknown Index types: ");
        for (String it : selectedIndexes)
            err.append(it).append(" ");
        System.err.println(err);
        exitWithHelp(options);
    }

    SDFTopologicalIndexer sdfIndexer = new SDFTopologicalIndexer(outFile, selectedIndexes);

    sdfIndexer.run(inFile);
    sdfIndexer.close();
}

From source file:org.anodyneos.jse.cron.CronDaemon.java

public static void main(String[] args) throws Exception {
    try {/*w w  w . ja  va2s.c om*/
        InputSource source = new InputSource(args[0]);
        CronDaemon server = new CronDaemon(source);
        server.start();
    } catch (Exception e) {
        log.fatal(e.getMessage(), e);
        throw e;
    }
}

From source file:co.cask.tigon.DistributedMain.java

public static void main(String[] args) {
    System.out.println("Tigon Distributed Client");
    if (args.length > 0) {
        if ("--help".equals(args[0]) || "-h".equals(args[0])) {
            usage(false);//from w  w  w.ja va2 s  .  c  om
            return;
        }

        if (args.length < 2) {
            usage(true);
        }

        String zkQuorumString = args[0];
        String rootNamespace = args[1];

        DistributedMain main = null;
        try {
            main = createDistributedMain(zkQuorumString, rootNamespace);
            main.startUp(System.out);
        } catch (Exception e) {
            LOG.error(e.getMessage(), e);
        } finally {
            try {
                if (main != null) {
                    main.shutDown();
                }
                TerminalFactory.get().restore();
            } catch (Exception e) {
                LOG.warn(e.getMessage(), e);
            }
        }
    }
}

From source file:com.turn.ttorrent.cli.TorrentMain.java

/**
 * Torrent reader and creator.//from   www.  ja v  a 2  s .  c om
 *
 * <p>
 * You can use the {@code main()} function of this class to read or create
 * torrent files. See usage for details.
 * </p>
 *
 */
public static void main(String[] args) {
    BasicConfigurator.configure(new ConsoleAppender(new PatternLayout("%-5p: %m%n")));

    CmdLineParser parser = new CmdLineParser();
    CmdLineParser.Option help = parser.addBooleanOption('h', "help");
    CmdLineParser.Option filename = parser.addStringOption('t', "torrent");
    CmdLineParser.Option create = parser.addBooleanOption('c', "create");
    CmdLineParser.Option pieceLength = parser.addIntegerOption('l', "length");
    CmdLineParser.Option announce = parser.addStringOption('a', "announce");

    try {
        parser.parse(args);
    } catch (CmdLineParser.OptionException oe) {
        System.err.println(oe.getMessage());
        usage(System.err);
        System.exit(1);
    }

    // Display help and exit if requested
    if (Boolean.TRUE.equals((Boolean) parser.getOptionValue(help))) {
        usage(System.out);
        System.exit(0);
    }

    String filenameValue = (String) parser.getOptionValue(filename);
    if (filenameValue == null) {
        usage(System.err, "Torrent file must be provided!");
        System.exit(1);
    }

    Integer pieceLengthVal = (Integer) parser.getOptionValue(pieceLength);
    if (pieceLengthVal == null) {
        pieceLengthVal = Torrent.DEFAULT_PIECE_LENGTH;
    } else {
        pieceLengthVal = pieceLengthVal * 1024;
    }
    logger.info("Using piece length of {} bytes.", pieceLengthVal);

    Boolean createFlag = (Boolean) parser.getOptionValue(create);

    //For repeated announce urls
    @SuppressWarnings("unchecked")
    Vector<String> announceURLs = (Vector<String>) parser.getOptionValues(announce);

    String[] otherArgs = parser.getRemainingArgs();

    if (Boolean.TRUE.equals(createFlag) && (otherArgs.length != 1 || announceURLs.isEmpty())) {
        usage(System.err,
                "Announce URL and a file or directory must be " + "provided to create a torrent file!");
        System.exit(1);
    }

    OutputStream fos = null;
    try {
        if (Boolean.TRUE.equals(createFlag)) {
            if (filenameValue != null) {
                fos = new FileOutputStream(filenameValue);
            } else {
                fos = System.out;
            }

            //Process the announce URLs into URIs
            List<URI> announceURIs = new ArrayList<URI>();
            for (String url : announceURLs) {
                announceURIs.add(new URI(url));
            }

            //Create the announce-list as a list of lists of URIs
            //Assume all the URI's are first tier trackers
            List<List<URI>> announceList = new ArrayList<List<URI>>();
            announceList.add(announceURIs);

            File source = new File(otherArgs[0]);
            if (!source.exists() || !source.canRead()) {
                throw new IllegalArgumentException(
                        "Cannot access source file or directory " + source.getName());
            }

            String creator = String.format("%s (ttorrent)", System.getProperty("user.name"));

            Torrent torrent = null;
            if (source.isDirectory()) {
                List<File> files = new ArrayList<File>(
                        FileUtils.listFiles(source, TrueFileFilter.TRUE, TrueFileFilter.TRUE));
                Collections.sort(files);
                torrent = Torrent.create(source, files, pieceLengthVal, announceList, creator);
            } else {
                torrent = Torrent.create(source, pieceLengthVal, announceList, creator);
            }

            torrent.save(fos);
        } else {
            Torrent.load(new File(filenameValue), true);
        }
    } catch (Exception e) {
        logger.error("{}", e.getMessage(), e);
        System.exit(2);
    } finally {
        if (fos != System.out) {
            IOUtils.closeQuietly(fos);
        }
    }
}

From source file:de.ailis.microblinks.blinks.compiler.Main.java

/**
 * Main method./*  w  ww  .ja  v a  2 s.  co m*/
 *
 * @param args
 *            The command-line arguments.
 */
public static void main(final String[] args) {
    final Main main = new Main();
    try {
        main.run(args);
    } catch (final Exception e) {
        if (main.debug) {
            log.error(e.toString(), e);
        } else {
            log.error(e.getMessage());
        }
        System.exit(1);
    }
}

From source file:com.clustercontrol.winservice.util.RequestWinRM.java

/**
 * /*from   w w w  . ja  v  a2  s . co m*/
 * @param args
 */
public static void main(String[] args) {
    try {
        RequestWinRM winRM = new RequestWinRM("SNMP");
        winRM.polling("172.26.98.119", "Administrator", "Hinemos24", 5985, "http", 3000, 5);

        System.out.println("MSG = " + winRM.getMessage());
        System.out.println("MSG_ORG = " + winRM.getMessageOrg());

        System.out.println(System.getProperty("javax.xml.transform.TransformerFactory"));

    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
}

From source file:com.genentech.chemistry.openEye.apps.SDFMDLSSSMatcher.java

public static void main(String... args) throws IOException, InterruptedException {
    oechem.OEUseJavaHeap(false);//from w ww. j  a v  a 2  s. co m

    // create command line Options object
    Options options = new Options();
    Option opt = new Option("in", true, "input file [.sdf,...]");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option("out", true, "output file oe-supported");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("ref", true, "refrence file with MDL query molecules");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option("anyMatch", false, "if set all matches are reported not just the first.");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("printAll", false, "if set even compounds that do not macht are outputted.");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("nCpu", true, "number of CPU's used in parallel, dafault 1");
    opt.setRequired(false);
    options.addOption(opt);

    CommandLineParser parser = new PosixParser();
    CommandLine cmd = null;
    try {
        cmd = parser.parse(options, args);
    } catch (Exception e) {
        System.err.println(e.getMessage());
        exitWithHelp(options);
    }

    args = cmd.getArgs();
    if (args.length > 0) {
        exitWithHelp("Unknown param: " + args[0], options);
    }

    if (cmd.hasOption("d")) {
        System.err.println("Start debugger and press return:");
        new BufferedReader(new InputStreamReader(System.in)).readLine();
    }

    int nCpu = 1;
    boolean firstMatch = !cmd.hasOption("anyMatch");
    boolean printAll = cmd.hasOption("printAll");

    String d = cmd.getOptionValue("nCpu");
    if (d != null)
        nCpu = Integer.parseInt(d);

    String inFile = cmd.getOptionValue("in");
    String outFile = cmd.getOptionValue("out");
    String refFile = cmd.getOptionValue("ref");

    SDFMDLSSSMatcher matcher = new SDFMDLSSSMatcher(refFile, outFile, firstMatch, printAll, nCpu);
    matcher.run(inFile);
    matcher.close();
}