List of usage examples for java.lang System exit
public static void exit(int status)
From source file:com.thoughtworks.go.utils.encryption.Encrypter.java
public static void main(String[] args) throws Exception { if (args.length != 1) { System.err.println("Usage: <executing jar> [path-to-go-cipher-file]"); System.err.println(// www .j ava 2s . c om "Example: java -cp goutils.jar com.thoughtworks.go.utils.encryption.Encrypter /etc/go/cipher"); System.exit(1); } String cipherLocation = args[0]; new Encrypter(cipherLocation).process(); }
From source file:org.n52.iceland.statistics.api.utils.KibanaExporter.java
public static void main(String args[]) throws Exception { if (args.length != 2) { System.out.printf("Usage: java KibanaExporter.jar %s %s\n", "localhost:9300", "my-cluster-name"); System.exit(0); }/*from www .j av a 2 s .c o m*/ if (!args[0].contains(":")) { throw new IllegalArgumentException( String.format("%s not a valid format. Expected <hostname>:<port>.", args[0])); } // set ES address String split[] = args[0].split(":"); InetSocketTransportAddress address = new InetSocketTransportAddress(InetAddress.getByName(split[0]), Integer.parseInt(split[1], 10)); // set cluster name Builder tcSettings = Settings.settingsBuilder(); tcSettings.put("cluster.name", args[1]); System.out.println("Connection to " + args[1]); client = TransportClient.builder().settings(tcSettings).build(); client.addTransportAddress(address); // search index pattern for needle searchIndexPattern(); KibanaConfigHolderDto holder = new KibanaConfigHolderDto(); System.out.println("Reading .kibana index"); SearchResponse resp = client.prepareSearch(".kibana").setSize(1000).get(); Arrays.asList(resp.getHits().getHits()).stream().map(KibanaExporter::parseSearchHit).forEach(holder::add); System.out.println("Reading finished"); ObjectMapper mapper = new ObjectMapper(); // we love pretty things mapper.enable(SerializationFeature.INDENT_OUTPUT); File f = new File("kibana_config.json"); try (FileOutputStream out = new FileOutputStream(f, false)) { mapper.writeValue(out, holder); } System.out.println("File outputted to: " + f.getAbsolutePath()); client.close(); }
From source file:jlite.cli.ProxyDestroy.java
public static void main(String[] args) { System.out.println(); // extra line CommandLineParser parser = new GnuParser(); Options options = setupOptions();//from www . ja v a 2 s.co m HelpFormatter helpFormatter = new HelpFormatter(); helpFormatter.setSyntaxPrefix("Usage: "); CommandLine line = null; try { line = parser.parse(options, args); if (line.hasOption("help")) { helpFormatter.printHelp(100, COMMAND, "\noptions:", options, "\n" + CLI.FOOTER, false); System.out.println(); // extra line System.exit(0); } if (line.hasOption("xml")) { System.out.println("<output>"); } run(line); } catch (ParseException e) { System.err.println(e.getMessage() + "\n"); helpFormatter.printHelp(100, COMMAND, "\noptions:", options, "\n" + CLI.FOOTER, false); System.out.println(); // extra line System.exit(-1); } catch (Exception e) { if (line.hasOption("xml")) { System.out.println("<error>" + e.getMessage() + "</error>"); } else { System.err.println(e.getMessage()); } } finally { System.out.println("</output>"); } System.out.println(); // extra line }
From source file:StylesExample4.java
public static void main(String[] args) { try {//from w ww . j a v a 2 s. c o m UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception evt) { } JFrame f = new JFrame("Styles Example 4"); // Create the StyleContext, the document and the pane StyleContext sc = new StyleContext(); final DefaultStyledDocument doc = new DefaultStyledDocument(sc); JTextPane pane = new JTextPane(doc); // Create and add the main document style Style defaultStyle = sc.getStyle(StyleContext.DEFAULT_STYLE); final Style mainStyle = sc.addStyle("MainStyle", defaultStyle); StyleConstants.setLeftIndent(mainStyle, 16); StyleConstants.setRightIndent(mainStyle, 16); StyleConstants.setFirstLineIndent(mainStyle, 16); StyleConstants.setFontFamily(mainStyle, "serif"); StyleConstants.setFontSize(mainStyle, 12); try { SwingUtilities.invokeAndWait(new Runnable() { public void run() { try { // Add the text to the document doc.insertString(0, text, null); // Set the logical style doc.setLogicalStyle(0, mainStyle); } catch (BadLocationException e) { } doc.dump(System.out); } }); } catch (Exception e) { System.out.println("Exception when constructing document: " + e); System.exit(1); } f.getContentPane().add(new JScrollPane(pane)); f.setSize(400, 300); f.setVisible(true); }
From source file:com.github.braully.graph.UtilResult.java
public static void main(String... args) throws Exception { Options options = new Options(); Option input = new Option("i", "input", true, "input file path"); input.setRequired(false);//w w w . ja va2s . c o m options.addOption(input); Option verb = new Option("v", "verbose", false, "verbose process"); input.setRequired(false); options.addOption(verb); Option output = new Option("o", "output", true, "output file"); output.setRequired(false); options.addOption(output); CommandLineParser parser = new DefaultParser(); HelpFormatter formatter = new HelpFormatter(); CommandLine cmd; try { cmd = parser.parse(options, args); } catch (ParseException e) { System.out.println(e.getMessage()); formatter.printHelp("UtilResult", options); System.exit(1); return; } String inputFilePath = cmd.getOptionValue("input"); if (inputFilePath == null) { inputFilePath = "/home/strike/grafos-para-processar/mft2/resultado.txt"; } if (inputFilePath != null) { if (inputFilePath.toLowerCase().endsWith(".txt")) { processFileTxt(inputFilePath); } else if (inputFilePath.toLowerCase().endsWith(".json")) { processFileJson(inputFilePath); } } }
From source file:com.rabbitmq.examples.PerfTest.java
public static void main(String[] args) { Options options = getOptions();//from w w w .ja va 2 s . c om CommandLineParser parser = new GnuParser(); try { CommandLine cmd = parser.parse(options, args); if (cmd.hasOption('?')) { usage(options); System.exit(0); } String exchangeType = strArg(cmd, 't', "direct"); String exchangeName = strArg(cmd, 'e', exchangeType); String queueName = strArg(cmd, 'u', ""); String routingKey = strArg(cmd, 'k', null); boolean randomRoutingKey = cmd.hasOption('K'); int samplingInterval = intArg(cmd, 'i', 1); float producerRateLimit = floatArg(cmd, 'r', 0.0f); float consumerRateLimit = floatArg(cmd, 'R', 0.0f); int producerCount = intArg(cmd, 'x', 1); int consumerCount = intArg(cmd, 'y', 1); int producerTxSize = intArg(cmd, 'm', 0); int consumerTxSize = intArg(cmd, 'n', 0); long confirm = intArg(cmd, 'c', -1); boolean autoAck = cmd.hasOption('a'); int multiAckEvery = intArg(cmd, 'A', 0); int channelPrefetch = intArg(cmd, 'Q', 0); int consumerPrefetch = intArg(cmd, 'q', 0); int minMsgSize = intArg(cmd, 's', 0); int timeLimit = intArg(cmd, 'z', 0); int producerMsgCount = intArg(cmd, 'C', 0); int consumerMsgCount = intArg(cmd, 'D', 0); List<?> flags = lstArg(cmd, 'f'); int frameMax = intArg(cmd, 'M', 0); int heartbeat = intArg(cmd, 'b', 0); boolean predeclared = cmd.hasOption('p'); String uri = strArg(cmd, 'h', "amqp://localhost"); //setup PrintlnStats stats = new PrintlnStats(1000L * samplingInterval, producerCount > 0, consumerCount > 0, (flags.contains("mandatory") || flags.contains("immediate")), confirm != -1); ConnectionFactory factory = new ConnectionFactory(); factory.setShutdownTimeout(0); // So we still shut down even with slow consumers factory.setUri(uri); factory.setRequestedFrameMax(frameMax); factory.setRequestedHeartbeat(heartbeat); MulticastParams p = new MulticastParams(); p.setAutoAck(autoAck); p.setAutoDelete(true); p.setConfirm(confirm); p.setConsumerCount(consumerCount); p.setConsumerMsgCount(consumerMsgCount); p.setConsumerRateLimit(consumerRateLimit); p.setConsumerTxSize(consumerTxSize); p.setExchangeName(exchangeName); p.setExchangeType(exchangeType); p.setFlags(flags); p.setMultiAckEvery(multiAckEvery); p.setMinMsgSize(minMsgSize); p.setPredeclared(predeclared); p.setConsumerPrefetch(consumerPrefetch); p.setChannelPrefetch(channelPrefetch); p.setProducerCount(producerCount); p.setProducerMsgCount(producerMsgCount); p.setProducerTxSize(producerTxSize); p.setQueueName(queueName); p.setRoutingKey(routingKey); p.setRandomRoutingKey(randomRoutingKey); p.setProducerRateLimit(producerRateLimit); p.setTimeLimit(timeLimit); MulticastSet set = new MulticastSet(stats, factory, p); set.run(true); stats.printFinal(); } catch (ParseException exp) { System.err.println("Parsing failed. Reason: " + exp.getMessage()); usage(options); } catch (Exception e) { System.err.println("Main thread caught exception: " + e); e.printStackTrace(); System.exit(1); } }
From source file:EchoFilterTest.java
public static void main(String[] args) { // load the sound SimpleSoundPlayer sound = new SimpleSoundPlayer("../sounds/voice.wav"); // create the sound stream InputStream is = new ByteArrayInputStream(sound.getSamples()); // create an echo with a 11025-sample buffer // (1/4 sec for 44100Hz sound) and a 60% decay EchoFilter filter = new EchoFilter(11025, .6f); // create the filtered sound stream is = new FilteredSoundStream(is, filter); // play the sound sound.play(is);/*from w ww .j a va2 s. co m*/ // due to bug in Java Sound, explicitly exit the VM. System.exit(0); }
From source file:cc.twittertools.index.ExtractTweetidsFromCollection.java
@SuppressWarnings("static-access") public static void main(String[] args) throws Exception { Options options = new Options(); options.addOption(OptionBuilder.withArgName("dir").hasArg().withDescription("source collection directory") .create(COLLECTION_OPTION)); CommandLine cmdline = null;//from w w w. ja va 2 s . c om CommandLineParser parser = new GnuParser(); try { cmdline = parser.parse(options, args); } catch (ParseException exp) { System.err.println("Error parsing command line: " + exp.getMessage()); System.exit(-1); } if (!cmdline.hasOption(COLLECTION_OPTION)) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(ExtractTweetidsFromCollection.class.getName(), options); System.exit(-1); } String collectionPath = cmdline.getOptionValue(COLLECTION_OPTION); File file = new File(collectionPath); if (!file.exists()) { System.err.println("Error: " + file + " does not exist!"); System.exit(-1); } StatusStream stream = new JsonStatusCorpusReader(file); Status status; while ((status = stream.next()) != null) { System.out.println(status.getId() + "\t" + status.getScreenname()); } }
From source file:com.pinterest.terrapin.server.TerrapinServerMain.java
public static void main(String[] args) { PropertiesConfiguration configuration = TerrapinUtil.readPropertiesExitOnFailure( System.getProperties().getProperty("terrapin.config", "server.properties")); try {/*from www. jav a 2s . c o m*/ final TerrapinServerHandler handler = new TerrapinServerHandler(configuration); handler.start(); Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { handler.shutdown(); } }); } catch (Throwable t) { LOG.error("Could not start up server.", t); System.exit(1); } }
From source file:io.github.dustalov.maxmax.Application.java
public static void main(String[] args) throws IOException { final CommandLineParser parser = new DefaultParser(); final Options options = new Options(); options.addOption(Option.builder("in").argName("in").desc("input graph in the ABC format").hasArg() .required().build());/*from w ww. j a v a 2 s.c o m*/ options.addOption(Option.builder("out").argName("out").desc("name of cluster output file").hasArg() .required().build()); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (final ParseException ex) { System.err.println(ex.getMessage()); final HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java -jar this.jar", options, true); System.exit(1); } final UndirectedGraph<String, DefaultWeightedEdge> graph = parse(cmd.getOptionValue("in"), ABCParser::parse); final MaxMax<String> maxmax = new MaxMax<>(graph); maxmax.run(); write(cmd.getOptionValue("out"), maxmax); }