List of usage examples for java.lang System exit
public static void exit(int status)
From source file:DashedRectangleDemo2D.java
public static void main(String s[]) { JFrame f = new JFrame(""); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); }/*from w w w.ja va 2 s .c o m*/ }); JApplet applet = new DashedRectangleDemo2D(); f.getContentPane().add("Center", applet); applet.init(); f.pack(); f.setSize(new Dimension(300, 300)); f.show(); }
From source file:XMLTransform.java
public static void main(String args[]) { if (args.length != 2) { System.err.println("Usage: java XMLTransform xmlfile.xml stylesheet.xsl"); System.exit(-1); }//from w w w. j ava 2 s . c om try { StreamSource source = new StreamSource(args[0]); StreamSource stylesource = new StreamSource(args[1]); TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(stylesource); StreamResult result = new StreamResult(System.out); transformer.transform(source, result); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.honnix.cheater.cli.Main.java
/** * @param args/*from ww w . j av a2 s . co m*/ * @throws SpcException */ public static void main(String[] args) throws SpcException { if (System.getProperty(CheaterConstant.TRUST_STORE_KEY) == null && !setTrustStore()) { LOG.fatal("Failed setting trust store. Use cheater.sh instead."); System.exit(1); } new CheaterImpl().start(); }
From source file:name.ikysil.beanpathdsl.codegen.CLI.java
/** * @param args the command line arguments */// www. j a v a 2 s . c om public static void main(String[] args) { final Options options = buildOptions(); try { CommandLineParser parser = new DefaultParser(); CommandLine cmdLine = parser.parse(options, args); if (cmdLine.hasOption("h")) { usage(options); System.exit(1); } Configuration configuration = new Configuration(); if (cmdLine.hasOption("s")) { configuration.setOutputDirectory(cmdLine.getOptionValue("s")); } if (cmdLine.hasOption("c")) { configuration.setOutputCharset(Charset.forName(cmdLine.getOptionValue("c"))); } if (cmdLine.hasOption("cnp")) { configuration.setClassNamePrefix(cmdLine.getOptionValue("cnp")); } if (cmdLine.hasOption("cns")) { configuration.setClassNameSuffix(cmdLine.getOptionValue("cns")); } if (cmdLine.hasOption("pnp")) { configuration.setPackageNamePrefix(cmdLine.getOptionValue("pnp")); } if (cmdLine.hasOption("pns")) { configuration.setPackageNameSuffix(cmdLine.getOptionValue("pns")); } new CodeGen(configuration).process(); } catch (ParseException ex) { System.err.println(String.format("Can not parse arguments: %s", ex.getMessage())); usage(options); } }
From source file:net.sf.jodreports.cli.CreateDocument.java
public static void main(String[] args) throws Exception { if (args.length < 3) { System.err.println("USAGE: " + CreateDocument.class.getName() + " <template-document> <data-file> <output-document>"); System.exit(0); }//from w ww .j av a2s . c o m File templateFile = new File(args[0]); File dataFile = new File(args[1]); File outputFile = new File(args[2]); DocumentTemplateFactory documentTemplateFactory = new DocumentTemplateFactory(); DocumentTemplate template = documentTemplateFactory.getTemplate(templateFile); Object model = null; String dataFileExtension = FilenameUtils.getExtension(dataFile.getName()); if (dataFileExtension.equals("xml")) { model = NodeModel.parse(dataFile); } else if (dataFileExtension.equals("properties")) { Properties properties = new Properties(); properties.load(new FileInputStream(dataFile)); model = properties; } else { throw new IllegalArgumentException( "data file must be 'xml' or 'properties'; unsupported type: " + dataFileExtension); } template.createDocument(model, new FileOutputStream(outputFile)); }
From source file:SAXCopy.java
static public void main(String[] arg) { String infilename = null;//w ww. j av a 2 s.c o m String outfilename = null; if (arg.length == 2) { infilename = arg[0]; outfilename = arg[1]; } else { usage(); } try { SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser parser = spf.newSAXParser(); XMLReader reader = parser.getXMLReader(); reader.setErrorHandler(new MyErrorHandler()); FileOutputStream fos = new FileOutputStream(outfilename); PrintWriter out = new PrintWriter(fos); MyCopyHandler duper = new MyCopyHandler(out); reader.setContentHandler(duper); InputSource is = new InputSource(infilename); reader.parse(is); out.close(); } catch (SAXException e) { System.exit(1); } catch (ParserConfigurationException e) { System.err.println(e); System.exit(1); } catch (IOException e) { System.err.println(e); System.exit(1); } }
From source file:Main.java
public static void main(String[] args) { Connection conn = null;/*from w w w .j a va2 s. c o m*/ Statement stmt = null; ResultSet rs = null; try { conn = getConnection(); String query = "select id, name from employees"; stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs = stmt.executeQuery(query); while (rs.next()) { String id = rs.getString(1); String name = rs.getString(2); System.out.println("id=" + id + " name=" + name); } rs.first(); rs.deleteRow(); rs.beforeFirst(); while (rs.next()) { String id = rs.getString(1); String name = rs.getString(2); System.out.println("id=" + id + " name=" + name); } } catch (Exception e) { e.printStackTrace(); System.exit(1); } finally { try { rs.close(); stmt.close(); conn.close(); } catch (SQLException e) { e.printStackTrace(); } } }
From source file:Main.java
public static void main(String[] args) throws Exception { Toolkit tk = Toolkit.getDefaultToolkit(); final Main main = new Main(); tk.addAWTEventListener(main, AWTEvent.WINDOW_EVENT_MASK); final JFrame frame = new JFrame(""); frame.setName("your frame"); JMenuBar mb = new JMenuBar(); JMenu menu = new JMenu("File"); menu.add(new AbstractAction("Quit") { public void actionPerformed(ActionEvent evt) { try { main.saveSettings();/* w w w. j a v a 2 s.c o m*/ System.exit(0); } catch (Exception ex) { System.out.println(ex); } } }); mb.add(menu); frame.setJMenuBar(mb); frame.pack(); frame.setVisible(true); }
From source file:NullLayoutPane.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); }/* w w w . j ava 2s .c om*/ }); frame.getContentPane().add(new NullLayoutPane(), BorderLayout.CENTER); // Finally, set the size of the main window, and pop it up. frame.setSize(600, 400); frame.setVisible(true); }
From source file:com.ok2c.lightmtp.examples.SendMailExample.java
public static void main(final String[] args) throws Exception { if (args.length < 3) { System.out.println("Usage: sender recipient1[;recipient2;recipient3;...] file"); System.exit(0); }//from www. j ava 2s . co m String sender = args[0]; List<String> recipients = new ArrayList<String>(); StringTokenizer tokenizer = new StringTokenizer(args[1], ";"); while (tokenizer.hasMoreTokens()) { String s = tokenizer.nextToken(); s = s.trim(); if (s.length() > 0) { recipients.add(s); } } File src = new File(args[2]); if (!src.exists()) { System.out.println("File '" + src + "' does not exist"); System.exit(0); } DeliveryRequest request = new BasicDeliveryRequest(sender, recipients, new FileSource(src)); MailUserAgent mua = new DefaultMailUserAgent(TransportType.SMTP, IOReactorConfig.DEFAULT); mua.start(); try { InetSocketAddress address = new InetSocketAddress("localhost", 2525); Future<DeliveryResult> future = mua.deliver(new SessionEndpoint(address), 0, request, null); DeliveryResult result = future.get(); System.out.println("Delivery result: " + result); } finally { mua.shutdown(); } }