List of usage examples for java.lang System exit
public static void exit(int status)
From source file:io.github.the28awg.okato.App.java
public static void main(String[] args) { Options options = new Options(); options.addOption(Option.builder().longOpt("token").hasArg().required().argName("token") .desc(" ? ? ??").build()); options.addOption(Option.builder("t").longOpt("type").hasArg().required().argName("type") .desc(" [city, street, building]").build()); options.addOption(Option.builder("q").longOpt("query").hasArg().argName("query") .desc(" ? ? ").build()); options.addOption(Option.builder("c").longOpt("city_id").hasArg().argName("city_id") .desc(" (? )").build()); options.addOption(Option.builder("s").longOpt("street_id").hasArg().argName("street_id") .desc(" ").build()); CommandLineParser parser = new DefaultParser(); HelpFormatter formatter = new HelpFormatter(); CommandLine cmd;//from ww w . j a v a 2 s .co m try { cmd = parser.parse(options, args); } catch (ParseException e) { System.out.println(e.getMessage()); formatter.printHelp("okato", options); System.exit(1); return; } AddressFactory.token(cmd.getOptionValue("token")); String arg_type = cmd.getOptionValue("type"); String arg_city_id = cmd.getOptionValue("city_id", ""); String arg_street_id = cmd.getOptionValue("street_id", ""); String arg_query = cmd.getOptionValue("query", ""); if (arg_type.equalsIgnoreCase("city")) { try { log(SimpleOkato.toSimpleResponse( AddressFactory.service().city(AddressFactory.token(), arg_query).execute().body())); } catch (IOException e) { e.printStackTrace(); } } else if (arg_type.equalsIgnoreCase("street")) { try { log(SimpleOkato.toSimpleResponse(AddressFactory.service() .street(AddressFactory.token(), arg_city_id, arg_query).execute().body())); } catch (IOException e) { e.printStackTrace(); } } else if (arg_type.equalsIgnoreCase("building")) { try { log(SimpleOkato.toSimpleResponse(AddressFactory.service() .building(AddressFactory.token(), arg_city_id, arg_street_id, arg_query).execute().body())); } catch (IOException e) { e.printStackTrace(); } } }
From source file:org.objectrepository.instruction.Console.java
/** * @param args args[0] - validate/create * args[1] - json structure example: {"instruction":{"na":"00000","fileSet":"./instruction-manager/src/test/resources/test-collection/","label":"My alias for a folder","resolverBaseUrl":"http://hdl.handle.net","lidPrefix":"HU:OSA:380:","access":"open","contentType":"image/jpg"}} * @throws Exception//ww w.j av a2s.c o m */ public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { InstructionType instructionType = InstructionTypeHelper.instructionTypeFromJson(args[0]); if (instructionType == null) { System.out.println("Expected InstructionType argument"); System.exit(1); } if (instructionType.getFileSet() == null) { System.out.println("Expected InstructionType.fileSet"); System.exit(1); } TaskType task = InstructionTypeHelper.firstTask(instructionType); if (task == null || task.getName() == null) { System.out.println("Expected InstructionType.task with a name set"); System.exit(1); } start(instructionType); System.exit(0); }
From source file:com.google.api.tools.framework.tools.configgen.ServiceConfigGeneratorTool.java
public static void main(String[] args) throws ParseException, IOException { ConfigGeneratorDriver.ensureStaticsInitialized(); ImmutableList<Option<?>> frameworkOptions = buildFrameworkOptions(); Options apacheCliOptions = ToolOptions.convertToApacheCliOptions(frameworkOptions); CommandLine cmd = (new BasicParser()).parse(apacheCliOptions, args); if (ToolOptions.isHelpFlagSet(cmd)) { ToolOptions.printUsage("ServiceConfigGeneratorTool", apacheCliOptions); System.exit(0); }//from w w w . ja v a2 s . co m ToolOptions toolOptions = ToolOptions.getToolOptionsFromCommandLine(cmd, frameworkOptions); System.exit(new ConfigGeneratorDriver(toolOptions).run()); }
From source file:ColorComboRenderer.java
public static void main(String[] a) { JComboBox cbColor = new JComboBox(); int[] values = new int[] { 0, 128, 192, 255 }; for (int r = 0; r < values.length; r++) for (int g = 0; g < values.length; g++) for (int b = 0; b < values.length; b++) { Color c = new Color(values[r], values[g], values[b]); cbColor.addItem(c);/* ww w . jav a 2 s . c o m*/ } cbColor.setRenderer(new ColorComboRenderer()); JFrame f = new JFrame(); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); f.getContentPane().add(cbColor); f.pack(); f.setSize(new Dimension(300, 80)); f.show(); }
From source file:com.sematext.ag.PlayerRunner.java
public static void main(String[] args) throws IOException { if (args.length != 1) { System.out.println("Usage: java com.sematext.ag.PlayerRunner <config-file>"); System.exit(1); }//from ww w .j ava 2 s. co m PlayerConfig config = new PlayerConfig(args[0]); play(config); }
From source file:com.apexxs.neonblack.setup.Setup.java
public static void main(String[] args) { Configuration config = Configuration.getInstance(); SolrLoader solrLoader = null;/* w w w . j av a2 s .com*/ int count = 0; SolrUtilities solrUtilities = new SolrUtilities(); if (!solrUtilities.checkCoreStatus("geonames")) { logger.error("Unable to establish connection to geonames core - Application terminated"); System.exit(-1); } if (!solrUtilities.checkCoreStatus("geodata")) { logger.error("Unable to establish connection to geodata core - Application terminated"); System.exit(-1); } logger.warn("Solr geonames and geodata indices will be cleared..."); SolrUtilities sutil = new SolrUtilities(); // sutil.clearSolrIndices(); long startTime = System.currentTimeMillis(); try { SolrServerFactory solrServerFactory = new SolrServerFactory(); SolrServer server = solrServerFactory.getConcurrentSolrServer("geonames"); // GeoNamesLoader geoNamesLoader = new GeoNamesLoader(); // System.out.println("***Loading Geonames gazetteer***"); // count = geoNamesLoader.load(server); // System.out.println("Committing and optimizing Geonames index...."); // server.commit(); // server.optimize(); // // System.out.println("Geonames index complete - inserted " + count + " documents."); server = solrServerFactory.getHTTPServer("geodata"); if (StringUtils.equalsIgnoreCase(config.getPolygonType(), "gadm")) { System.out.println("***Loading GADM Border polygons***"); solrLoader = new GADMBorderLoader(); count = solrLoader.load(server); } else if (StringUtils.equalsIgnoreCase(config.getPolygonType(), "ne")) { System.out.println("***Loading Natural Earth Border polygons***"); solrLoader = new NaturalEarthLoader(); count = solrLoader.load(server); } else { System.out.println("***Loading Thematicmapping polygons***"); solrLoader = new TMBorderLoader(); count = solrLoader.load(server); solrLoader = new StateBorderLoader(); count += solrLoader.load(server); } System.out.println("Committing and optimizing Geodata index...."); server.commit(); server.optimize(); server.shutdown(); System.out.println("***Loaded " + count + " polygons***"); } catch (Exception ex) { logger.error("Error loading SOLR indices - " + ex.getMessage()); } long endTime = System.currentTimeMillis(); System.out.println("***Solr Index load complete***"); System.out.println("Elapsed time: " + (endTime - startTime) / 60000 + " minutes"); }
From source file:com.textocat.textokit.postagger.opennlp.GeneratePipelineDescriptorForOpenNLPPosTagger.java
public static void main(String[] args) throws UIMAException, IOException, SAXException { if (args.length != 1) { System.err.println("Provide output path!"); System.exit(1); }//from www .ja va 2 s . co m File outFile = new File(args[0]); // AnalysisEngineDescription outDesc = getDescription(); OutputStream out = FileUtils.openOutputStream(outFile); try { outDesc.toXML(out); } finally { IOUtils.closeQuietly(out); } }
From source file:com.mosso.client.cloudfiles.sample.FilesMakeContainer.java
public static void main(String args[]) throws NoSuchAlgorithmException, FilesException { //Build the command line options Options options = addCommandLineOptions(); if (args.length <= 0) printHelp(options);/*w w w.j av a 2s. c om*/ CommandLineParser parser = new GnuParser(); try { // parse the command line arguments CommandLine line = parser.parse(options, args); if (line.hasOption("help")) printHelp(options); String containerName = null; if (line.hasOption("container")) { containerName = line.getOptionValue("container"); createContaier(containerName); } //end if (line.hasOption("container")) else if (args.length > 0) { //If we got this far there are command line arguments but none of what we expected treat the first one as the Container name containerName = args[0]; createContaier(containerName); } else { System.err.println("You must provide the -container with a valid value for this to work !"); System.exit(-1); } } //end try catch (ParseException err) { System.err.println("Please see the logs for more details. Error Message: " + err.getMessage()); err.printStackTrace(System.err); } //catch( ParseException err ) catch (IOException err) { System.err.println("Please see the logs for more details. Error Message: " + err.getMessage()); } //catch ( IOException err) }
From source file:net.orpiske.sas.service.main.Main.java
public static void main(String[] args) { int ret = 0;//from w w w.j ava 2 s. c om if (args.length == 0) { help(1); } try { ConfigurationWrapper.initConfiguration(Constants.SAS_SERVICE_CONFIG_DIR, Constants.CONFIG_FILE_NAME); } catch (ConfigurationException e) { System.err.println("Unable to load configuration file " + "'mdm-broker.properties': " + e.getMessage()); System.exit(-1); } catch (FileNotFoundException e) { System.err.println("Unable to find configuration file " + "'mdm-broker.properties': " + e.getMessage()); System.exit(-1); } String first = args[0]; String[] newArgs = Arrays.copyOfRange(args, 1, args.length); if (first.equals("run")) { RunAction runAction = new RunAction(newArgs); ret = runAction.run(); System.exit(ret); } help(-1); }
From source file:com.rackspacecloud.client.cloudfiles.sample.FilesMakeContainer.java
public static void main(String args[]) throws NoSuchAlgorithmException, FilesException { //Build the command line options Options options = addCommandLineOptions(); if (args.length <= 0) printHelp(options);//from w w w. j a va 2 s .co m CommandLineParser parser = new GnuParser(); try { // parse the command line arguments CommandLine line = parser.parse(options, args); if (line.hasOption("help")) printHelp(options); String containerName = null; if (line.hasOption("container")) { containerName = line.getOptionValue("container"); createContaier(containerName); } //end if (line.hasOption("container")) else if (args.length > 0) { //If we got this far there are command line arguments but none of what we expected treat the first one as the Container name containerName = args[0]; createContaier(containerName); } else { System.err.println("You must provide the -container with a valid value for this to work !"); System.exit(-1); } } //end try catch (ParseException err) { System.err.println("Please see the logs for more details. Error Message: " + err.getMessage()); err.printStackTrace(System.err); } //catch( ParseException err ) catch (Exception err) { System.err.println("Please see the logs for more details. Error Message: " + err.getMessage()); } //catch ( IOException err) }