List of usage examples for java.lang System exit
public static void exit(int status)
From source file:ShowOff.java
public static void main(String[] args) { try {/* w ww .j a v a 2s .c om*/ String filename = "largeJava2sLogo.jpg"; String message = "Java Source and Support"; int split = 4; JFrame f = new JFrame(); f.getContentPane().setLayout(new BorderLayout()); ShowOff showOff = new ShowOff(filename, message, split); f.add(showOff, BorderLayout.CENTER); f.setSize(f.getPreferredSize()); f.setResizable(false); f.setVisible(true); } catch (Exception e) { System.out.println(e); System.exit(0); } }
From source file:se.patrikbergman.java.cxf.example.client.Client.java
public static void main(String args[]) throws Exception { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( new String[] { "client-beans.xml" }); HelloWorld client = (HelloWorld) context.getBean("client"); String response = client.sayHi("Joe"); System.out.println("Response: " + response); System.exit(0); }
From source file:GridBagWithAnchor.java
public static void main(String[] args) { JFrame f = new JFrame("Demonstrates the use of anchor constraints"); JPanel p = new JPanel(new GridBagLayout()); p.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(2, 2, 2, 2); c.weighty = 1.0;/* w w w. ja v a2 s .com*/ c.weightx = 1.0; c.gridx = 0; c.gridy = 0; c.gridheight = 2; c.anchor = GridBagConstraints.NORTH; // place component on the North p.add(new JButton("Java"), c); c.gridx = 1; c.gridheight = 1; c.gridwidth = 2; c.anchor = GridBagConstraints.SOUTHWEST; p.add(new JButton("Source"), c); c.gridy = 1; c.gridwidth = 1; c.anchor = GridBagConstraints.CENTER; // remember to rest to center p.add(new JButton("and"), c); c.gridx = 2; p.add(new JButton("Support !!!"), c); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; f.addWindowListener(wndCloser); f.getContentPane().add(p); f.setSize(600, 200); f.show(); }
From source file:OneFourDialog.java
public static void main(String args[]) throws Exception { String filename = args[0];//from w w w .ja v a 2s . c o m PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet(); DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF; PrintService printService[] = PrintServiceLookup.lookupPrintServices(flavor, pras); PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService(); PrintService service = ServiceUI.printDialog(null, 200, 200, printService, defaultService, DocFlavor.INPUT_STREAM.GIF, pras); if (service != null) { DocPrintJob job = service.createPrintJob(); PrintJobListener listener = new PrintJobAdapter() { public void printDataTransferCompleted(PrintJobEvent e) { System.exit(0); } }; job.addPrintJobListener(listener); FileInputStream fis = new FileInputStream(filename); DocAttributeSet das = new HashDocAttributeSet(); Doc doc = new SimpleDoc(fis, flavor, das); job.print(doc, pras); Thread.sleep(10000); } }
From source file:Main.java
public static void main(String[] args) throws Exception { String deptName = "oldName"; String newDeptName = "newName"; ResultSet rs = null;/*from ww w. j a v a 2 s . c o m*/ Connection conn = null; PreparedStatement pstmt = null; PreparedStatement pstmt2 = null; try { conn = getConnection(); // prepare query for getting a REF object and PrepareStatement object String refQuery = "select manager from dept_table where dept_name=?"; pstmt = conn.prepareStatement(refQuery); pstmt.setString(1, deptName); rs = pstmt.executeQuery(); java.sql.Ref ref = null; if (rs.next()) { ref = rs.getRef(1); } if (ref == null) { System.out.println("error: could not get a reference for manager."); System.exit(1); } String query = "INSERT INTO dept_table(dept_name, manager)values(?, ?)"; pstmt2 = conn.prepareStatement(query); pstmt2.setString(1, newDeptName); pstmt2.setRef(2, ref); // execute query, and return number of rows created int rowCount = pstmt2.executeUpdate(); System.out.println("rowCount=" + rowCount); } finally { pstmt.close(); pstmt2.close(); conn.close(); } }
From source file:com.example.customerservice.client.CustomerServiceSpringClient.java
public static void main(String args[]) throws Exception { // Initialize the spring context and fetch our test client ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( new String[] { "classpath:client-applicationContext.xml" }); CustomerServiceTester client = (CustomerServiceTester) context.getBean("tester"); client.testCustomerService();// w w w . j a v a 2 s . c om System.exit(0); }
From source file:Main.java
public static void main(String[] args) throws Exception { String deptName = "oldName"; String newDeptName = "newName"; ResultSet rs = null;/* ww w . j a v a2 s .co m*/ Connection conn = null; PreparedStatement pstmt = null; PreparedStatement pstmt2 = null; try { conn = getConnection(); // prepare query for getting a REF object and PrepareStatement object String refQuery = "select manager from dept_table where dept_name=?"; pstmt = conn.prepareStatement(refQuery); pstmt.setString(1, deptName); rs = pstmt.executeQuery(); java.sql.Ref ref = null; if (rs.next()) { ref = rs.getRef("manager"); } if (ref == null) { System.out.println("error: could not get a reference for manager."); System.exit(1); } String query = "INSERT INTO dept_table(dept_name, manager)values(?, ?)"; pstmt2 = conn.prepareStatement(query); pstmt2.setString(1, newDeptName); pstmt2.setRef(2, ref); // execute query, and return number of rows created int rowCount = pstmt2.executeUpdate(); System.out.println("rowCount=" + rowCount); } finally { pstmt.close(); pstmt2.close(); conn.close(); } }
From source file:TestConnectToMoreThanOneDatabase.java
public static void main(String[] args) { Connection oracleConn = null; Connection mysqlConn = null;//from w w w .j a v a 2s. c om try { oracleConn = getOracleConnection(); mysqlConn = getMySqlConnection(); System.out.println("oracleConn=" + oracleConn); System.out.println("mysqlConn=" + mysqlConn); } catch (Exception e) { // handle the exception e.printStackTrace(); System.exit(1); } finally { // release database resources try { oracleConn.close(); mysqlConn.close(); } catch (SQLException e) { e.printStackTrace(); } } }
From source file:com.basingwerk.utilisation.Utilisation.java
public static void main(final String[] args) { String dataFile = null;//from ww w . ja v a 2s .c om Options options = new Options(); Option helpOption = new Option("h", "help", false, "print this help"); Option serverURLOption = new Option("l", "logfile", true, "log file"); options.addOption(helpOption); options.addOption(serverURLOption); CommandLineParser argsParser = new PosixParser(); try { CommandLine commandLine = argsParser.parse(options, args); if (commandLine.hasOption(helpOption.getOpt())) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("Usage grapher", options); System.exit(0); } dataFile = commandLine.getOptionValue(serverURLOption.getOpt()); String[] otherArgs = commandLine.getArgs(); if (dataFile == null || otherArgs.length > 1) { System.out.println("Please specify a logfile"); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("Usage grapher", options); System.exit(0); } } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { } final UsagePlotter demo = new UsagePlotter("Usage", new File(dataFile)); demo.pack(); RefineryUtilities.centerFrameOnScreen(demo); demo.setVisible(true); }
From source file:demos.Main.java
public static void main(String[] args) throws Exception { try {// w w w. ja va2 s . com CommandLineParser parser = new PosixParser(); CommandLine cmdLine = parser.parse(getOptions(), args); int status = run(cmdLine); System.exit(status); } catch (ParseException e) { printUsage(); System.exit(STATUS_SHOW_USAGE); } }