List of usage examples for java.lang Exception getMessage
public String getMessage()
From source file:com.microsoft.azure.management.compute.samples.CreateVirtualMachinesInParallel.java
/** * Main entry point.//from w w w .j ava 2s. c om * @param args the parameters */ public static void main(String[] args) { try { //============================================================= // Authenticate // System.out.println("AZURE_AUTH_LOCATION_2=" + System.getenv("AZURE_AUTH_LOCATION_2")); final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION_2")); Azure azure = Azure.configure().withLogLevel(LogLevel.NONE).authenticate(credFile) .withDefaultSubscription(); // Print selected subscription System.out.println("Selected subscription: " + azure.subscriptionId()); runSample(azure); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } }
From source file:com.mycompany.asyncreq.Main.java
public static void main(String[] args) throws JsonProcessingException, JSONException, IOException { Configuration config = new Configuration(); // Name tables with lowercase_underscore_separated RestTemplate restTemplate = new RestTemplate(); config.setNamingStrategy(new ImprovedNamingStrategy()); try {//from w ww .ja v a2 s. c o m ArrayList<String> ArrReq = GenData(); String addr; for (Iterator<String> i = ArrReq.iterator(); i.hasNext();) { try { addr = i.next(); Thread.sleep(1000); Root tRoot = restTemplate.getForObject(addr, Root.class); tRoot.addr = addr; if (!tRoot.dataset.isEmpty()) if (tRoot.dataset.size() == tRoot.validation.count.value) ObjToCsv(tRoot, "all"); else { for (int reg = 1; reg < 5; reg++) { Thread.sleep(1000); addr = "http://comtrade.un.org/api/get?max=50000&type=C&freq=M&px=HS&ps=2014&r=804&p=" + tRoot.dataset.get(0).getptCode() + "&rg=" + reg + "&cc=All&fmt=json"; Root tRootImp = restTemplate.getForObject(addr, Root.class); tRootImp.addr = addr; if (!tRootImp.dataset.isEmpty()) if (tRootImp.dataset.size() == tRootImp.validation.count.value) ObjToCsv(tRootImp, Integer.toString(reg)); else System.out.println("addr: " + tRootImp.addr + "\n"); } } else System.out.println("addr: " + tRoot.addr + ":null" + "\n"); } catch (Exception e) { System.err.println(e.getMessage()); } } } catch (Exception e) { System.err.println("Got an exception! "); System.err.println(e.getMessage()); } }
From source file:com.genentech.chemistry.openEye.apps.SDFCatsIndexer.java
/** * @param args// w w w . ja v a 2s . c o m */ 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); opt = new Option(OPT_NORMALIZATION, true, "Normalization method: Counts|CountsPerAtom|CountsPerFeature(def) multiple allowed"); opt.setArgName("meth"); options.addOption(opt); opt = new Option(OPT_PRINTDESC, false, "Causes the descriptor for describing each linear path in a molceule to be created"); options.addOption(opt); opt = new Option(OPT_RGROUPTYPES, false, "treat RGroup attachement point ([U]) as atom type."); 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); } String inFile = cmd.getOptionValue(OPT_INFILE); String outFile = cmd.getOptionValue(OPT_OUTFILE); AtomTyperInterface[] myTypes = CATSIndexer.typers; String tagPrefix = ""; if (cmd.hasOption(OPT_RGROUPTYPES)) { myTypes = CATSIndexer.rgroupTypers; tagPrefix = "RG"; } if (cmd.hasOption(OPT_PRINTDESC)) { SDFCatsIndexer sdfIndexer = new SDFCatsIndexer(myTypes, tagPrefix); sdfIndexer.printDescriptors(inFile, outFile); sdfIndexer.close(); return; } EnumSet<Normalization> normMeth = EnumSet.noneOf(Normalization.class); if (cmd.hasOption(OPT_NORMALIZATION)) for (String n : cmd.getOptionValues(OPT_NORMALIZATION)) normMeth.add(Normalization.valueOf(n)); else normMeth.add(Normalization.CountsPerFeature); SDFCatsIndexer sdfIndexer = new SDFCatsIndexer(myTypes, tagPrefix); sdfIndexer.run(inFile, outFile, normMeth); sdfIndexer.close(); }
From source file:com.krawler.esp.handlers.genericFileUpload.java
public static void main(String args[]) { try {/*from w w w .ja v a2s.co m*/ genericFileUpload a = new genericFileUpload(); a.imgResizeCompany("/home/mosin/images/pics/aragorn.jpg", 1300, 1000, "/home/mosin/images/pics/test", true); } catch (Exception e) { logger.warn(e.getMessage(), e); } }
From source file:de.binfalse.jatter.App.java
/** * Run jatter's main./*w ww.j a v a 2 s .c om*/ * * @param args * the arguments * @throws Exception * the exception */ public static void main(String[] args) throws Exception { Options options = new Options(); Option conf = new Option("c", "config", true, "config file path"); conf.setRequired(false); options.addOption(conf); Option t = new Option("t", "template", false, "show a config template"); t.setRequired(false); options.addOption(t); Option v = new Option("v", "verbose", false, "print information messages"); v.setRequired(false); options.addOption(v); Option d = new Option("d", "debug", false, "print debugging messages incl stack traces"); d.setRequired(false); options.addOption(d); Option h = new Option("h", "help", false, "show help"); h.setRequired(false); options.addOption(h); CommandLineParser parser = new DefaultParser(); CommandLine cmd; try { cmd = parser.parse(options, args); if (cmd.hasOption("h")) throw new RuntimeException("showing the help page"); } catch (Exception e) { help(options, e.getMessage()); return; } if (cmd.hasOption("t")) { System.out.println(); BufferedReader br = new BufferedReader(new InputStreamReader( App.class.getClassLoader().getResourceAsStream("config.properties.template"))); while (br.ready()) System.out.println(br.readLine()); br.close(); System.exit(0); } if (cmd.hasOption("v")) LOGGER.setMinLevel(LOGGER.INFO); if (cmd.hasOption("d")) { LOGGER.setMinLevel(LOGGER.DEBUG); LOGGER.setLogStackTrace(true); } if (!cmd.hasOption("c")) help(options, "a config file is required for running jatter"); startJatter(cmd.getOptionValue("c")); }
From source file:org.atomserver.core.dbstore.utils.DBPurger.java
public static void main(String[] args) { if (args.length < 1 || args.length > 2) { throw new IllegalArgumentException("args.length < 1 || args.length > 2"); }//w ww. ja va 2s . com String workspace = args[0]; String collection = null; if (args.length == 2) { collection = args[1]; } if (log.isDebugEnabled()) log.debug("workspace= " + workspace + " collection= " + collection); try { getInstance().purge(workspace, collection); } catch (Exception ee) { System.out.println("Exception = " + ee.getClass().getName() + " message= " + ee.getMessage()); ee.printStackTrace(); System.out.println("Could NOT purge " + workspace + " " + collection); System.exit(123); } }
From source file:it.geosolutions.geobatch.jetty.Start.java
public static void main(String[] args) { Server server = null;// w w w. j a v a 2s. c o m SocketConnector conn = null; try { server = new Server(); // TODO pass properties file File properties = null; if (args.length == 1) { String propertiesFileName = args[0]; if (!propertiesFileName.isEmpty()) { properties = new File(propertiesFileName); } } else { properties = new File("src/test/resources/jetty.properties"); } Properties prop = loadProperties(properties); // load properties into system env setSystemProperties(prop); server.setHandler(configureContext(prop)); conn = configureConnection(prop); server.setConnectors(new Connector[] { conn }); server.start(); // use this to test normal stop behavior, that is, to check stuff // that // need to be done on container shutdown (and yes, this will make // jetty stop just after you started it...) // jettyServer.stop(); } catch (Throwable e) { log.error("Could not start the Jetty server: " + e.getMessage(), e); if (server != null) { try { server.stop(); } catch (Exception e1) { log.error("Unable to stop the Jetty server:" + e1.getMessage(), e1); } } if (conn != null) { try { conn.stop(); } catch (Exception e1) { log.error("Unable to stop the connection:" + e1.getMessage(), e1); } } } }
From source file:com.microsoft.azure.management.appservice.samples.ManageWebAppSourceControl.java
/** * Main entry point.//from ww w.j av a2 s .c o m * @param args the parameters */ public static void main(String[] args) { try { //============================================================= // Authenticate final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION")); Azure azure = Azure.configure().withLogLevel(LogLevel.BASIC).authenticate(credFile) .withDefaultSubscription(); // Print selected subscription System.out.println("Selected subscription: " + azure.subscriptionId()); runSample(azure); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } }
From source file:net.mitnet.tools.pdf.book.openoffice.ui.cli.OpenOfficeDocConverterCLI.java
public static void main(String[] arguments) throws Exception { CommandLineParser commandLineParser = new PosixParser(); CommandLine commandLine = commandLineParser.parse(OPTIONS, arguments); CommandLineHelper commandLineHelper = new CommandLineHelper(commandLine); if (!commandLineHelper.hasOption(CliOptions.OPTION_INPUT_DIR)) { System.err.println("Must specify " + CliOptions.OPTION_INPUT_DIR.getDescription()); showHelp();// w ww . ja v a2 s . c o m } File sourceDir = commandLineHelper.getOptionValueAsFile(CliOptions.OPTION_INPUT_DIR); if (!commandLineHelper.hasOption(CliOptions.OPTION_OUTPUT_DIR)) { System.err.println("Must specify " + CliOptions.OPTION_OUTPUT_DIR.getDescription()); showHelp(); } File outputDir = commandLineHelper.getOptionValueAsFile(CliOptions.OPTION_OUTPUT_DIR); int openOfficePort = 8100; if (commandLineHelper.hasOption(CliOptions.OPTION_OPEN_OFFICE_PORT)) { openOfficePort = commandLineHelper.getOptionValueAsInt(CliOptions.OPTION_OPEN_OFFICE_PORT); } String openOfficeHost = "localhost"; if (commandLineHelper.hasOption(CliOptions.OPTION_OPEN_OFFICE_HOST)) { openOfficeHost = commandLineHelper.getOptionValue(CliOptions.OPTION_OPEN_OFFICE_HOST); } String outputFormat = DEFAULT_OUTPUT_FORMAT; if (commandLineHelper.hasOption(CliOptions.OPTION_OUTPUT_FORMAT)) { outputFormat = commandLineHelper.getOptionValue(CliOptions.OPTION_OUTPUT_FORMAT); } boolean verbose = false; if (commandLineHelper.hasOption(CliOptions.OPTION_VERBOSE)) { verbose = true; } //OpenOfficeConnection connection = new SocketOpenOfficeConnection(openOfficeHost, openOfficePort); OfficeManager officeManager = new DefaultOfficeManagerConfiguration().setPortNumber(8100) .buildOfficeManager(); try { if (verbose) { System.out.println( "-- connecting to OpenOffice.org host " + openOfficeHost + " on port " + openOfficePort); } //connection.connect(); officeManager.start(); } catch (Exception ce) { ce.printStackTrace(System.err); System.err.println(ce.getMessage()); String msg = "ERROR: connection failed. Please make sure OpenOffice.org is running on host " + openOfficeHost + " and listening on port " + openOfficePort + "."; System.err.println(msg); System.exit(SystemExitValues.EXIT_CODE_CONNECTION_FAILED); } try { if (verbose) { System.out.println("Source dir is " + sourceDir); System.out.println("Output dir is " + outputDir); System.out.println("Output format is " + outputFormat); System.out.println("Converting files ..."); } ProgressMonitor progressMonitor = new ConsoleProgressMonitor(); OpenOfficeDocConverter docConverter = new OpenOfficeDocConverter(openOfficeHost, openOfficePort); docConverter.setVerboseEnabled(verbose); docConverter.setProgressMonitor(progressMonitor); docConverter.convertDocuments(sourceDir, outputDir, outputFormat); } finally { if (verbose) { System.out.println("-- disconnecting"); } //connection.disconnect(); officeManager.stop(); System.out.println("Finished converting files."); } }
From source file:com.genentech.retrival.tabExport.TABExporter.java
public static void main(String[] args) throws ParseException, JDOMException, IOException { long start = System.currentTimeMillis(); int nStruct = 0; // create command line Options object Options options = new Options(); Option opt = new Option("sqlFile", true, "sql-xml file"); opt.setRequired(true);// w ww . j a va2 s. c o m options.addOption(opt); opt = new Option("sqlName", true, "name of SQL element in xml file"); opt.setRequired(true); options.addOption(opt); opt = new Option("o", true, "output file"); opt.setRequired(false); options.addOption(opt); opt = new Option("newLineReplacement", true, "If given newlines in fields will be replaced by this string."); options.addOption(opt); opt = new Option("noHeader", false, "Do not output header line"); options.addOption(opt); CommandLineParser parser = new BasicParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (Exception e) { System.err.println(e.getMessage()); exitWithHelp(options); } args = cmd.getArgs(); String outFile = cmd.getOptionValue("o"); String sqlFile = cmd.getOptionValue("sqlFile"); String sqlName = cmd.getOptionValue("sqlName"); String newLineReplacement = cmd.getOptionValue("newLineReplacement"); args = cmd.getArgs(); try { PrintStream out = System.out; if (outFile != null) out = new PrintStream(outFile); SQLStatement stmt = SQLStatement.createFromFile(new File(sqlFile), sqlName); Object[] sqlArgs = args; if (stmt.getParamTypes().length != args.length) { System.err.printf( "\nWarining sql statement needs %d parameters but got only %d. Filling up with NULLs.\n", stmt.getParamTypes().length, args.length); sqlArgs = new Object[stmt.getParamTypes().length]; System.arraycopy(args, 0, sqlArgs, 0, args.length); } Selecter sel = Selecter.factory(stmt); if (!sel.select(sqlArgs)) { System.err.println("No rows returned!"); System.exit(0); } String[] fieldNames = sel.getFieldNames(); if (fieldNames.length == 0) { System.err.println("Query did not return any columns"); exitWithHelp(options); } if (!cmd.hasOption("noHeader")) { StringBuilder sb = new StringBuilder(200); for (String f : fieldNames) sb.append(f).append('\t'); if (sb.length() > 1) sb.setLength(sb.length() - 1); // chop last \t String header = sb.toString(); out.println(header); } StringBuilder sb = new StringBuilder(200); while (sel.hasNext()) { Record sqlRec = sel.next(); sb.setLength(0); for (int i = 0; i < fieldNames.length; i++) { String fld = sqlRec.getStrg(i); if (newLineReplacement != null) fld = NEWLinePattern.matcher(fld).replaceAll(newLineReplacement); sb.append(fld).append('\t'); } if (sb.length() > 1) sb.setLength(sb.length() - 1); // chop last \t String row = sb.toString(); out.println(row); nStruct++; } } catch (Exception e) { throw new Error(e); } finally { System.err.printf("TABExporter: Exported %d records in %dsec\n", nStruct, (System.currentTimeMillis() - start) / 1000); } }