List of usage examples for java.lang System exit
public static void exit(int status)
From source file:com.flipkart.poseidon.jmx.PoseidonJMXInvoker.java
public static void main(String[] args) { if (args.length < 3) { System.err.println(PoseidonJMXInvoker.class.getSimpleName() + " <host> <port> <operation>"); System.exit(-1); }//from ww w .ja v a 2 s. co m final String CONNECT_STRING = args[0] + ":" + args[1]; final String OPERATION = args[2]; try { System.out.println("Running " + OPERATION + " over JMX on " + CONNECT_STRING); JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + CONNECT_STRING + "/jmxrmi"); MBeanServerConnection connection = JMXConnectorFactory.connect(url).getMBeanServerConnection(); connection.invoke(ObjectName.getInstance(MBEAN_NAME), OPERATION, null, null); } catch (Exception e) { if (!(ExceptionUtils.getRootCause(e) instanceof EOFException && "destroy".equals(OPERATION))) { e.printStackTrace(); System.exit(-1); } } System.out.println(OPERATION + " successful over JMX on " + CONNECT_STRING); }
From source file:com.jkoolcloud.client.samples.query.QueryData1.java
public static void main(String[] args) { try {/*from w ww. j a va 2 s .com*/ Properties props = new Properties(); props.setProperty(JKCmdOptions.PROP_URI, JKQuery.JKOOL_QUERY_URL); JKCmdOptions options = new JKCmdOptions(QueryData1.class, args, props); if (options.usage != null) { System.out.println(options.usage); System.exit(-1); } options.print(); JKQuery jkQuery = new JKQuery(options.token); HttpResponse response = jkQuery.get(options.query); System.out.println(EntityUtils.toString(response.getEntity())); } catch (Exception e) { e.printStackTrace(); } }
From source file:br.com.asisprojetos.mailreport.Main.java
public static void main(String args[]) { logger.debug("Testando debug"); if (args.length < 2) { logger.error("Erro : Numero de parametros errados."); System.exit(1); }//from w w w . j av a 2s . co m String dataIniProc = String.format("%s 00:00:00", args[0]); String dataFimProc = String.format("%s 23:59:59", args[1]); logger.debug("Data Inicial: {} , Data Final: {}", dataIniProc, dataFimProc); String mes = String.format("%s/%s", args[0].substring(5, 7), args[0].substring(0, 4)); ApplicationContext context = new ClassPathXmlApplicationContext("Spring-Datasource.xml"); TBRelatorioEmailDAO tbRelatorioEmailDAO = (TBRelatorioEmailDAO) context.getBean("TBRelatorioEmailDAO"); List<TBRelatorioEmail> listaRelatorioEmail = tbRelatorioEmailDAO.getAll(); for (TBRelatorioEmail tbRelatorioEmail : listaRelatorioEmail) { logger.debug(" CodContrato: {}, CodProduto: {}", tbRelatorioEmail.getCodContrato(), tbRelatorioEmail.getCodProduto()); List<String> listaEmails = tbRelatorioEmailDAO.getListaEmails(tbRelatorioEmail.getCodContrato()); if (!listaEmails.isEmpty()) { logger.debug("Lista de Emails obtida : [{}] ", listaEmails); //List<String> listaCodProduto = Arrays.asList( StringUtils.split(tbRelatorioEmail.getCodProduto(), ';') ) ; List<String> listaCodProduto = new ArrayList<String>(); listaCodProduto.add("1");//Sped Fiscal logger.debug("Gerando Relatorio Geral de Consumo por Produto..."); List<String> fileNames = new ArrayList<String>(); String fileName; BarChartDemo barChartDemo = (BarChartDemo) context.getBean("BarChartDemo"); //fileName = barChartDemo.generateBarChartGraph(tbRelatorioEmail.getCodContrato()); //fileNames.add(fileName); fileNames = barChartDemo.generateBarChartGraph2(tbRelatorioEmail.getCodContrato()); String templateFile = null; for (String codProduto : listaCodProduto) { if (codProduto.equals(Produto.SPED_FISCAL.getCodProduto())) { logger.debug("Produto Codigo : {} ", codProduto); templateFile = "index6.html"; //grafico de diagnostico fileName = barChartDemo.generateDiagnosticGraph(tbRelatorioEmail.getCodContrato(), dataIniProc, dataFimProc); fileNames.add(fileName); //grafico de auditoria recorrente fileName = barChartDemo.generateRecurrentGraph(tbRelatorioEmail.getCodContrato(), dataIniProc, dataFimProc); fileNames.add(fileName); } else { logger.debug("Produto Codigo : {} no aceito para gerar grafico ", codProduto); } logger.debug("Enviando Email.............Produto Codigo : {}", codProduto); SendEmail sendEmail = (SendEmail) context.getBean("SendEmail"); sendEmail.enviar(listaEmails.toArray(new String[listaEmails.size()]), "Relatrio Mensal de Riscos Fiscais", templateFile, fileNames, mes, tbRelatorioEmail.getCodContrato()); //sendEmail.enviar( new String[]{"leandro.prates@asisprojetos.com.br","leandro.prates@gmail.com"} , // "Relatrio Mensal de Riscos Fiscais", templateFile, fileNames, mes, tbRelatorioEmail.getCodContrato() ); } //Remover todos os arquivos png gerado para o cliente Config config = (Config) context.getBean("Config"); for (String f : fileNames) { try { File file = new File(String.format("%s/%s", config.getOutDirectory(), f)); if (file.delete()) { logger.debug("Arquivo: [{}/{}] deletado com sucesso.", config.getOutDirectory(), f); } else { logger.error("Erro ao deletar o arquivo: [{}/{}]", config.getOutDirectory(), f); } } catch (Exception ex) { logger.error("Erro ao deletar o arquivo: [{}/{}] . Message {}", config.getOutDirectory(), f, ex); } } } } }
From source file:IconPaint.java
public static void main(String[] args) { Image starImage = Toolkit.getDefaultToolkit().getImage(IconPaint.iconFile); IconPanel starPanel = new IconPanel(starImage); JFrame f = new JFrame("Icon"); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); }/*from w w w . j av a2 s . c o m*/ }); f.getContentPane().add(starPanel, BorderLayout.CENTER); f.setSize(new Dimension(550, 200)); f.setVisible(true); }
From source file:test.node.TestNodeWorker.java
public static void main(String[] args) { try {// w ww . ja va2s . c om log.info("GridNode Starting..."); StopWatch sw = new StopWatch(); sw.start(); // Start Grid Node GridNode node = Grid.startGridNode(); sw.stop(); log.info("GridNode Started Up. [" + sw.getLastTaskTimeMillis() + " ms]"); log.info("GridNode ID : " + node.getId()); log.debug("Press any key to unregister GridNode and terminate"); System.in.read(); node.getNodeRegistrationService().unregister(); log.info("Unregistered, Terminating..."); System.exit(0); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.alertlogic.aws.kinesis.test1.utils.DeleteSampleResources.java
public static void main(String[] args) { if (args.length != 4) { System.err.println("Usage: " + DeleteSampleResources.class.getSimpleName() + " <application name> <stream name> <DynamoDB table name> <region>"); System.exit(1); }/*w ww. j a v a2s . c o m*/ String applicationName = args[0]; String streamName = args[1]; String countsTableName = args[2]; Region region = SampleUtils.parseRegion(args[3]); AWSCredentialsProvider credentialsProvider = new DefaultAWSCredentialsProviderChain(); ClientConfiguration clientConfig = SampleUtils.configureUserAgentForSample(new ClientConfiguration()); AmazonKinesis kinesis = new AmazonKinesisClient(credentialsProvider, clientConfig); kinesis.setRegion(region); AmazonDynamoDB dynamoDB = new AmazonDynamoDBClient(credentialsProvider, clientConfig); dynamoDB.setRegion(region); StreamUtils streamUtils = new StreamUtils(kinesis); DynamoDBUtils dynamoDBUtils = new DynamoDBUtils(dynamoDB); LOG.info("Removing Amazon Kinesis and DynamoDB resources used by the sample application..."); streamUtils.deleteStream(streamName); // The Kinesis Client Library creates a table to manage shard leases and uses the application name for its name. dynamoDBUtils.deleteTable(applicationName); dynamoDBUtils.deleteTable(countsTableName); }
From source file:demo.wssec.client.Client.java
public static void main(String args[]) throws Exception { if (args.length == 0) { System.out.println("please specify wsdl"); System.exit(1); }//from ww w. ja v a 2s . c om URL wsdlURL; File wsdlFile = new File(args[0]); if (wsdlFile.exists()) { wsdlURL = wsdlFile.toURI().toURL(); } else { wsdlURL = new URL(args[0]); } SpringBusFactory bf = new SpringBusFactory(); URL busFile = new ClassPathResource("wssec-client.xml").getURL(); Bus bus = bf.createBus(busFile.toString()); SpringBusFactory.setDefaultBus(bus); SpringBusFactory.setThreadDefaultBus(bus); Service service = Service.create(wsdlURL, SERVICE_NAME); Greeter port = service.getPort(PORT_NAME, Greeter.class); System.out.println("Invoking greetMe..."); try { String resp = port.greetMe(System.getProperty("user.name")); System.out.println("Server responded with: " + resp); System.out.println(); } catch (Exception e) { System.out.println("Invocation failed with the following: " + e.getCause()); System.out.println(); } System.exit(0); }
From source file:almira.sample.client.ListCatapults.java
/** * Main function./*from w ww. j a v a2s .com*/ * * @param args the serviceUrl as command line argument. */ @SuppressWarnings("unchecked") public static void main(String[] args) { if (args.length != 1) { printMessage("Usage: java -jar client.jar <serviceUrl>"); System.exit(1); } HttpInvokerProxyFactoryBean fb = getFactoryBeanInstance(args[0]); executeQuery((ObjectQueryService<Catapult, Long>) fb.getObject()); }
From source file:com.sapienter.jbilling.tools.ConvertToBinHexa.java
/** * @param args/*from w ww . j a v a 2s . c o m*/ */ public static void main(String[] args) { String driver = null; if (args.length < 3) { System.err.println("Usage: url username password [driver]"); System.exit(1); return; } if (args.length < 4) { driver = "org.postgresql.Driver"; } else { driver = args[3]; } System.out.println("Converting credit cards ... "); int count = 0; try { connection = getConnection(args[0], args[1], args[2], driver); ResultSet rows = getCCRowsToUpdate(); while (rows == null) { //rows.next() - skip CC int rowId = rows.getInt(1); String cryptedNumber = rows.getString(2); String cryptedName = rows.getString(3); int userId = rows.getInt(4); JBCrypto oldCrypt = JBCrypto.getCreditCardCrypto(); oldCrypt.setUseHexForBinary(false); String plainNumber; try { plainNumber = oldCrypt.decrypt(cryptedNumber); } catch (Exception e) { plainNumber = "Not available"; System.out.println("User id " + userId + " cc id " + rowId + " with bad cc number"); } String plainName; try { plainName = oldCrypt.decrypt(cryptedName); } catch (RuntimeException e) { plainName = "Not available"; System.out.println("User id " + userId + " cc id " + rowId + " with bad cc name"); } // now recrypt using the new way JBCrypto newCrypt = JBCrypto.getCreditCardCrypto(); newCrypt.setUseHexForBinary(true); cryptedName = newCrypt.encrypt(plainName); cryptedNumber = newCrypt.encrypt(plainNumber); //System.out.println("new " + cryptedName + " and " + cryptedNumber); updateCCRow(rowId, cryptedName, cryptedNumber); count++; } rows.close(); System.out.println("Converting user passwords ... "); count = 0; rows = getUserRowsToUpdate(); while (rows.next()) { int rowId = rows.getInt(1); String oldPassword = rows.getString(2); try { String newPassword = Util.binaryToString(Base64.decodeBase64(oldPassword.getBytes())); System.out.println("new " + newPassword + " old " + oldPassword); updateUserRow(rowId, newPassword); count++; } catch (Exception e) { System.out.println("Error with password " + oldPassword + " :" + e.getMessage()); } } rows.close(); connection.close(); } catch (Exception e) { System.err.println("Error! " + e.getMessage()); e.printStackTrace(); System.exit(2); } System.out.println("Finished! " + count + " rows populated"); }
From source file:org.huahinframework.manager.Runner.java
/** * @param args/*ww w .ja v a 2 s . c o m*/ */ public static void main(String[] args) { if (args.length != 2) { System.err.println("argument error: [war path] [port]"); System.exit(-1); } String war = args[0]; int port = Integer.valueOf(args[1]); Runner runner = new Runner(); runner.start(war, port); System.exit(0); }