List of usage examples for java.lang Throwable getMessage
public String getMessage()
From source file:com.xafero.vee.cmd.MainApp.java
public static void main(String[] args) { // Define options Option help = new Option("?", "help", false, "print this message"); Option version = new Option("v", "version", false, "print the version information and exit"); Option eval = Option.builder("e").desc("evaluate script").argName("file").longOpt("eval").hasArg().build(); Option list = new Option("l", "list", false, "print all available languages"); // Collect them Options options = new Options(); options.addOption(help);// w w w. j av a 2 s.co m options.addOption(version); options.addOption(eval); options.addOption(list); // If nothing given, nothing will happen if (args == null || args.length < 1) { printHelp(options); return; } // Parse command line try { CommandLineParser parser = new DefaultParser(); CommandLine line = parser.parse(options, args); // Work on it process(line, options); } catch (Throwable e) { System.err.printf("Error occurred: %n " + e.getMessage()); } }
From source file:dk.dma.ais.utils.aisbus.AisBusLauncher.java
public static void main(String[] args) throws Exception { Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() { @Override/*from w w w . j a va 2s. c o m*/ public void uncaughtException(Thread t, Throwable e) { LOG.error("Uncaught exception in thread " + t.getClass().getCanonicalName() + ": " + e.getMessage(), e); System.exit(-1); } }); new AisBusLauncher().execute(args); }
From source file:com.dattack.dbtools.drules.DrulesClient.java
/** * Main() method./* www. j a va 2 s .c om*/ * * @param args * the arguments */ public static void main(final String[] args) { try { execute(args); System.exit(0); } catch (final Throwable e) { // NOPMD by cvarela on 20/02/16 13:19 LOGGER.error(e.getMessage(), e); System.exit(-1); } }
From source file:esg.gateway.client.ESGAccessLogClient.java
public static void main(String[] args) { String serviceHost = null;//from ww w . ja va 2 s. co m long startTime = 0; long endTime = Long.MAX_VALUE; try { serviceHost = args[0]; startTime = Long.parseLong(args[1]); endTime = Long.parseLong(args[2]); } catch (Throwable t) { log.error(t.getMessage()); } try { ESGAccessLogClient client = new ESGAccessLogClient(); if (client.setEndpoint(serviceHost).ping()) { List<String[]> results = null; results = client.fetchAccessLogData(startTime, endTime); System.out.println("---results:[" + (results.size() - 1) + "]---"); for (String[] record : results) { StringBuilder sb = new StringBuilder(); for (String column : record) { sb.append("[" + column + "] "); } System.out.println(sb.toString()); } } System.out.println("-----------------"); } catch (Throwable t) { log.error(t); t.printStackTrace(); } }
From source file:org.mzd.shap.spring.cli.ConfigSetup.java
public static void main(String[] args) { // check args if (args.length != 1) { exitOnError(1, null);//from w ww. j a va 2s . c om } // check file existance File analyzerXML = new File(args[0]); if (!analyzerXML.exists()) { exitOnError(1, "'" + analyzerXML.getPath() + "' did not exist\n"); } // prompt user whether existing data should be purged boolean isPurged = false; String ormContext = null; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); try { System.out.println("\nDo you wish to purge the database before running setup?"); System.out.println("WARNING: all existing data in SHAP will be lost!"); System.out.println("Really purge? yes/[NO]"); String ans = br.readLine(); if (ans.toLowerCase().equals("yes")) { System.out.println("Purging enabled"); ormContext = "orm-purge-context.xml"; isPurged = true; } else { System.out.println("Purging disabled"); ormContext = "orm-context.xml"; } } catch (IOException ex) { throw new RuntimeException(ex); } // run tool try { // Using a generic application context since we're referencing // both classpath and filesystem resources. GenericApplicationContext ctx = new GenericApplicationContext(); XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(ctx); xmlReader.loadBeanDefinitions(new ClassPathResource("datasource-context.xml"), new ClassPathResource(ormContext), new FileSystemResource(analyzerXML)); ctx.refresh(); /* * Create an base admin user. */ if (isPurged) { //only attempted if we've wiped the old database. RoleDao roleDao = (RoleDao) ctx.getBean("roleDao"); Role adminRole = roleDao.saveOrUpdate(new Role("admin", "ROLE_ADMIN")); Role userRole = roleDao.saveOrUpdate(new Role("user", "ROLE_USER")); UserDao userDao = (UserDao) ctx.getBean("userDao"); userDao.saveOrUpdate(new User("admin", "admin", "shap01", adminRole, userRole)); } /* * Create some predefined analyzers. Users should have modified * the configuration file to suit their environment. */ AnnotatorDao annotatorDao = (AnnotatorDao) ctx.getBean("annotatorDao"); DetectorDao detectorDao = (DetectorDao) ctx.getBean("detectorDao"); ConfigSetup config = (ConfigSetup) ctx.getBean("configuration"); for (Annotator an : config.getAnnotators()) { System.out.println("Adding annotator: " + an.getName()); annotatorDao.saveOrUpdate(an); } for (Detector dt : config.getDetectors()) { System.out.println("Adding detector: " + dt.getName()); detectorDao.saveOrUpdate(dt); } System.exit(0); } catch (Throwable t) { System.err.println(t.getMessage()); System.exit(1); } }
From source file:com.notifier.desktop.Main.java
public static void main(String[] args) { Options options = createCommandLineOptions(); try {/*from w w w . j a v a 2s. c o m*/ CommandLineParser commandLineParser = new GnuParser(); CommandLine line = commandLineParser.parse(options, args); if (line.getOptions().length > 1) { showMessage("Only one parameter may be specified"); } if (line.getArgs().length > 0) { showMessage("Non-recognized parameters: " + Arrays.toString(line.getArgs())); } if (line.hasOption(HELP_SHORT)) { printHelp(options); return; } if (line.hasOption(IS_RUNNING_SHORT)) { ServiceClient client = new ServiceClientImpl(); if (client.isRunning()) { showMessage(Application.NAME + " is running"); } else { showMessage(Application.NAME + " is not running"); } return; } if (line.hasOption(STOP_SHORT)) { ServiceClient client = new ServiceClientImpl(); if (client.stop()) { showMessage("Sent stop signal to " + Application.NAME + " successfully"); } else { showMessage(Application.NAME + " is not running or an error occurred, see log for details"); } return; } boolean trayIcon = !line.hasOption(NO_TRAY_SHORT); boolean showPreferences = line.hasOption(SHOW_PREFERENCES_SHORT); if (!getExclusiveExecutionLock()) { showMessage("There can be only one instance of " + Application.NAME + " running at a time"); return; } Injector injector = Guice.createInjector(Stage.PRODUCTION, new ApplicationModule()); Application application = injector.getInstance(Application.class); application.start(trayIcon, showPreferences); } catch (Throwable t) { System.out.println(t.getMessage()); logger.error("Error starting", t); } }
From source file:de.speexx.csv.table.app.Application.java
public static void main(final String... args) { try {/* w w w . ja v a 2 s . co m*/ new Application().run(args); } catch (final Throwable t) { LOG.error("Unexpected end of application: {}", t.getMessage()); final StackTraceElement[] st = t.getStackTrace(); LOG.error("Location - class: {} - method: {} - line: {}", st[0].getClassName(), st[0].getMethodName(), st[0].getLineNumber()); System.exit(1); } System.exit(0); }
From source file:ch.bender.evacuate.EvacuateMain.java
/** * main// w w w . j a v a2 s. c o m * <p> * @param args * @throws IOException */ public static void main(String[] args) throws IOException { try { myLog.debug("Evacuate starting"); EvacuateMain eva = new EvacuateMain(args); eva.init(); eva.run(); myLog.debug("Successfully terminated"); } catch (Throwable t) { myLog.error(t.getMessage(), t); } }
From source file:it.geosolutions.geobatch.jetty.Start.java
public static void main(String[] args) { Server server = null;/*www. j a v a2s .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.zotoh.maedr.etc.AppRunner.java
/** * @param args//from ww w .ja v a 2 s. c om */ public static void main(String[] args) { boolean cloud = false; try { for (int i = 0; i < args.length; ++i) { if ("cloud".equals(args[i])) { cloud = true; break; } } if (!parseArgs(args)) { throw new CmdHelpError(); } } catch (AppDirError e) { System.out.println("You must run the command in the application directory."); } catch (CmdHelpError e) { if (cloud) { usage_cloud(); } else { usage(); } } catch (Throwable t) { tlog().error("", t); //t.printStackTrace(); System.out.println(t.getMessage()); } }