List of usage examples for java.lang System exit
public static void exit(int status)
From source file:org.excalibur.client.ApplicationDeploymentClient.java
public static void main(String[] args) throws JsonParseException, JsonMappingException, IOException { JCommander jc = new JCommander(); for (Command command : COMMANDS.values()) { jc.addCommand(command.getName(), command); }/*from w w w .j a v a 2s . com*/ try { jc.parse(args); Command command = COMMANDS.get(jc.getParsedCommand()); if (command == null) { jc.usage(); System.exit(1); } command.execute(System.out); } catch (ParameterException ex) { jc.usage(); } }
From source file:com.dhenton9000.java.mongo.MongoTest.java
public static void main(String[] args) { MongoClient mongoClient = null;/* w w w . j a va 2 s. c o m*/ try { // mongoClient = new MongoClient("localhost", 27017); MongoClientURI mu = new MongoClientURI( "mongodb://mongouser:mongo9000@ds029811.mongolab.com:29811/restaurant_collection"); mongoClient = new MongoClient(mu); } catch (UnknownHostException ex) { LOG.error("unknown host error localhost"); System.exit(25); } LOG.debug("start "); MongoTest mongoTest = new MongoTest(); try { // mongoTest.collectionDemo(mongoClient); // mongoTest.writeDemo(mongoClient); mongoTest.loadData(mongoClient); } catch (Exception ex) { LOG.error("could not find file " + ex.getMessage()); System.exit(34); } mongoClient.close(); LOG.debug("end"); }
From source file:org.ala.hbase.IconicSpeciesLoader.java
/** * @param args/*from w ww . j a v a 2s .c o m*/ */ public static void main(String[] args) throws Exception { ApplicationContext context = SpringUtils.getContext(); IconicSpeciesLoader l = context.getBean(IconicSpeciesLoader.class); l.load(); System.exit(0); }
From source file:com.blackberry.logtools.loggrep.java
public static void main(String[] argv) throws Exception { //Let ToolRunner handle generic command-line options int res = ToolRunner.run(new Configuration(), new loggrep(), argv); System.exit(res); }
From source file:com.preferanser.server.client.DealUploader.java
public static void main(String[] args) throws IOException, URISyntaxException { if (args.length < 3) { System.out.println("Usage: DealUploader <server-url> <auth-cookie> <json-dir>"); System.exit(1); }//from w ww. j a v a 2s . c o m new DealUploader(args[0], args[1], args[2]).start(); }
From source file:de.moritzrupp.stockreader.Main.java
/** * main//w ww .ja va2s.c o m * @param args */ public static void main(String[] args) { initOptions(); clParser = new GnuParser(); if (args.length == 0) { // if no arguments formatter.printHelp("stockreader", header, options, footer); System.exit(1); } try { CommandLine line = clParser.parse(options, args); if (line.hasOption("h")) { printHelp(); } if (line.hasOption("v")) { System.out.println("stockreader version " + VERSION + ". Copyright 2013 by Moritz Rupp. All rights reserved.\n" + "This application is licensed under The MIT License (MIT). See https://github.com/moritzrupp/stockreader/blob/master/LICENSE.md"); System.exit(0); } if (line.hasOption("p")) { priceArg = true; } if (line.hasOption("f")) { fileArg = true; theFile = new File(line.getOptionValue("f")); } host = line.getOptionValue("host"); username = line.getOptionValue("user"); passwd = line.getOptionValue("password"); from = line.getOptionValue("from"); to = line.getOptionValue("to"); } catch (ParseException exp) { // TODO Auto-generated catch block exp.printStackTrace(); } try { reader = new StockReader(';', new StockQuote(), "UTF-8", (fileArg) ? theFile.toString() : new File(".").getCanonicalPath() + ((System.getProperty("os.name").toLowerCase().startsWith("win")) ? "\\" : "/") + "stocks.csv"); for (int i = 0; i < args.length; i++) { switch (args[i].charAt(0)) { case '-': if (args[i].length() < 2) { System.err.println("Not a valid argument: " + args[i]); printHelp(); System.exit(1); } if (args[i].charAt(1) == 'f' || (args[i].charAt(1) == '-' && args[i].charAt(2) == 'f')) { // get the path and set it to "nosymbol" args[i + 1] = "nosymbol"; } break; default: if (!args[i].equals("nosymbol")) { reader.addSymbol(args[i]); } break; } } reader.getQuotes(); reader.writeToCSV(priceArg); reader.sendmail(from, to, "Aktienkurse", host, username, passwd); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JAXBException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (java.text.ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:org.rotarysource.standalone.ServerShellMain.java
public static void main(String[] args) throws Exception { try {//from w w w . ja v a 2s . c o m log.info("System properties information : file.encoding=" + Charset.defaultCharset().name()); new ServerShellMain(); } catch (Exception t) { log.error("Error starting server shell: " + t.getMessage(), t); System.exit(-1); } }
From source file:com.blackberry.logtools.logsearch.java
public static void main(String[] argv) throws Exception { //Let ToolRunner handle generic command-line options int res = ToolRunner.run(new Configuration(), new logsearch(), argv); System.exit(res); }
From source file:com.devti.JavaXMPPBot.FakeDaemonContext.java
public static void main(String[] args) { JavaXMPPBot daemon = new JavaXMPPBot(); try {/*from w w w . j a v a2s. c o m*/ daemon.init(new FakeDaemonContext(args)); daemon.start(); while (Thread.activeCount() > 1) { Thread.sleep(1000); } } catch (Exception e) { e.printStackTrace(); //System.err.println("Can't load a bot: " + e.getLocalizedMessage()); System.exit(1); } }
From source file:com.sebuilder.interpreter.SeInterpreter.java
public static void main(String[] args) { if (args.length == 0) { System.out.println(// ww w. ja v a 2 s . co m "Usage: [--driver=<drivername] [--driver.<configkey>=<configvalue>...] [--implicitlyWait=<ms>] [--pageLoadTimeout=<ms>] [--stepTypePackage=<package name>] <script path>..."); System.exit(0); } Log log = LogFactory.getFactory().getInstance(SeInterpreter.class); WebDriverFactory wdf = DEFAULT_DRIVER_FACTORY; ScriptFactory sf = new ScriptFactory(); StepTypeFactory stf = new StepTypeFactory(); sf.setStepTypeFactory(stf); TestRunFactory trf = new TestRunFactory(); sf.setTestRunFactory(trf); ArrayList<String> paths = new ArrayList<String>(); HashMap<String, String> driverConfig = new HashMap<String, String>(); for (String s : args) { if (s.startsWith("--")) { String[] kv = s.split("=", 2); if (kv.length < 2) { log.fatal("Driver configuration option \"" + s + "\" is not of the form \"--driver=<name>\" or \"--driver.<key>=<value\"."); System.exit(1); } if (s.startsWith("--implicitlyWait")) { trf.setImplicitlyWaitDriverTimeout(Integer.parseInt(kv[1])); } else if (s.startsWith("--pageLoadTimeout")) { trf.setPageLoadDriverTimeout(Integer.parseInt(kv[1])); } else if (s.startsWith("--stepTypePackage")) { stf.setPrimaryPackage(kv[1]); } else if (s.startsWith("--driver.")) { driverConfig.put(kv[0].substring("--driver.".length()), kv[1]); } else if (s.startsWith("--driver")) { try { wdf = (WebDriverFactory) Class .forName("com.sebuilder.interpreter.webdriverfactory." + kv[1]).newInstance(); } catch (ClassNotFoundException e) { log.fatal("Unknown WebDriverFactory: " + "com.sebuilder.interpreter.webdriverfactory." + kv[1], e); } catch (InstantiationException e) { log.fatal("Could not instantiate WebDriverFactory " + "com.sebuilder.interpreter.webdriverfactory." + kv[1], e); } catch (IllegalAccessException e) { log.fatal("Could not instantiate WebDriverFactory " + "com.sebuilder.interpreter.webdriverfactory." + kv[1], e); } } else { paths.add(s); } } else { paths.add(s); } } if (paths.isEmpty()) { log.info("Configuration successful but no paths to scripts specified. Exiting."); System.exit(0); } HashMap<String, String> cfg = new HashMap<String, String>(driverConfig); for (String path : paths) { try { TestRun lastRun = null; for (Script script : sf.parse(new File(path))) { for (Map<String, String> data : script.dataRows) { try { lastRun = script.testRunFactory.createTestRun(script, log, wdf, driverConfig, data, lastRun); if (lastRun.finish()) { log.info(script.name + " succeeded"); } else { log.info(script.name + " failed"); } } catch (Exception e) { log.info(script.name + " failed", e); } } } } catch (Exception e) { log.fatal("Run error.", e); System.exit(1); } } }