List of usage examples for java.lang System exit
public static void exit(int status)
From source file:GeneralPathOpenDemo2D.java
public static void main(String s[]) { JFrame f = new JFrame(""); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); }//from ww w . j a va2 s . c o m }); JApplet applet = new GeneralPathOpenDemo2D(); f.getContentPane().add("Center", applet); applet.init(); f.pack(); f.setSize(new Dimension(300, 300)); f.show(); }
From source file:edu.gmu.isa681.client.Main.java
public static void main(String[] args) { log.info("Setting look and feel..."); try {// w w w . j a v a2 s .c o m for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception ex1) { log.warn(ex1.getMessage(), ex1); log.warn("Nimbus is not available."); log.warn("Switching to system look and feel"); log.warn("Some GUI discrepancies may occur!"); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception ex2) { log.error(ex2.getMessage(), ex2); log.error("Could not setup a look and feel."); System.exit(1); } } log.info("Initializing GUI..."); final JFrame frame = new JFrame(); frame.setTitle("GoForward"); frame.setBackground(new Color(0, 100, 0)); UIManager.put("nimbusBase", new Color(0, 100, 0)); //UIManager.put("nimbusBlueGrey", new Color(0, 100, 0)); UIManager.put("control", new Color(0, 100, 0)); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { frame.setPreferredSize(frame.getSize()); } }); Dimension dim = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); if (dim.width < 1366) { frame.setPreferredSize(new Dimension(800, 600)); } else { frame.setPreferredSize(new Dimension(1200, 700)); } //frame.setResizable(false); frame.setLocationByPlatform(true); frame.pack(); Client client = new Client("localhost", Constants.SERVER_PORT); Controller controller = new Controller(client, frame); controller.applicationStarted(); frame.setLocationRelativeTo(null); frame.setVisible(true); log.info("Started"); }
From source file:com.chiralBehaviors.autoconfigure.debug.TemplateDebugger.java
public static void main(String[] argv) throws JsonParseException, JsonMappingException, IOException { if (argv.length == 0) { System.out.println("Usage: TemplateDebugger <scenario file>+"); System.exit(1); }/* w w w. j a v a 2 s . co m*/ ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); for (String fileName : argv) { FileInputStream yaml = new FileInputStream(fileName); TemplateDebugger debugger = mapper.readValue(yaml, TemplateDebugger.class); System.out.println("======================================"); System.out.println(String.format("Rendered output of %s", yaml)); System.out.println("======================================"); System.out.println(); System.out.println(debugger.render()); System.out.println(); System.out.println("======================================"); System.out.println(); System.out.println(); } }
From source file:TestDebug_MySQL.java
public static void main(String[] args) { Connection conn = null;/*from ww w . j ava2s .c o m*/ try { PrintWriter pw = new PrintWriter(new FileOutputStream("mysql_debug.txt")); DriverManager.setLogWriter(pw); conn = getConnection(); String tableName = "myTable"; System.out.println("tableName=" + tableName); System.out.println("conn=" + conn); System.out.println("rowCount=" + countRows(conn, tableName)); } catch (Exception e) { e.printStackTrace(); System.exit(1); } finally { try { conn.close(); } catch (SQLException e) { e.printStackTrace(); } } }
From source file:GeneralPathDemo2D.java
public static void main(String s[]) { JFrame f = new JFrame(""); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); }// w w w. j a v a 2 s . c om }); JApplet applet = new GeneralPathDemo2D(); f.getContentPane().add("Center", applet); applet.init(); f.pack(); f.setSize(new Dimension(300, 300)); f.show(); }
From source file:edu.anu.spice.SpiceScorer.java
public static void main(String[] args) { if (args.length < 1) { SpiceArguments.printUsage();// www . j a va 2 s .co m System.exit(2); } SpiceArguments spiceArgs = new SpiceArguments(args); try { SpiceScorer scorer = new SpiceScorer(); scorer.scoreBatch(spiceArgs); } catch (Exception ex) { System.err.println("Error: Could not score batched file input:"); ex.printStackTrace(); System.exit(1); } }
From source file:Main.java
public static void main(String[] args) { if (args.length == 0) { System.out.println(/*ww w . java2 s . c o m*/ "usage: java ClassFinder <class name>\n\n" + "example: java ClassFinder java.lang.String\n"); System.exit(0); } File cwd = new File("."); File[] archives = cwd.listFiles(new ArchiveFilter()); String classFileName = args[0].replace('.', '/'); if (classFileName.endsWith(".class") == false) { classFileName += ".class"; } System.out.println("Searching for " + classFileName + " ..."); for (int j = 0; j < archives.length; j++) { // System.out.println("Searching " + archives[j].getName()); if (searchJarFile(archives[j], classFileName)) { System.out.println("FOUND IN " + archives[j].getName()); } } }
From source file:examples.rexec.java
public static final void main(String[] args) { String server, username, password, command; RExecClient client;//from ww w . j av a 2 s. co m if (args.length != 4) { System.err.println("Usage: rexec <hostname> <username> <password> <command>"); System.exit(1); return; // so compiler can do proper flow control analysis } client = new RExecClient(); server = args[0]; username = args[1]; password = args[2]; command = args[3]; try { client.connect(server); } catch (IOException e) { System.err.println("Could not connect to server."); e.printStackTrace(); System.exit(1); } try { client.rexec(username, password, command); } catch (IOException e) { try { client.disconnect(); } catch (IOException f) { } e.printStackTrace(); System.err.println("Could not execute command."); System.exit(1); } IOUtil.readWrite(client.getInputStream(), client.getOutputStream(), System.in, System.out); try { client.disconnect(); } catch (IOException e) { e.printStackTrace(); System.exit(1); } System.exit(0); }
From source file:ch.systemsx.cisd.openbis.generic.server.dataaccess.db.DatabaseAndIndexReplacer.java
public static void main(String[] args) { if (args.length != 4) { System.out.println("Usage: java " + DatabaseAndIndexReplacer.class.getName() + " <destination database kind> <destination index folder> " + "<source database kind> <source index folder>"); System.exit(1); }/*from ww w . ja v a 2 s . c o m*/ LogInitializer.init(); String destinationDatabase = IndexCreationUtil.DATABASE_NAME_PREFIX + args[0]; File destinationFolder = new File(args[1]); String sourceDatabase = IndexCreationUtil.DATABASE_NAME_PREFIX + args[2]; File sourceFolder = new File(args[3]); boolean ok = IndexCreationUtil.duplicateDatabase(destinationDatabase, sourceDatabase); if (ok == false) { System.exit(1); } FileUtilities.deleteRecursively(destinationFolder); try { FileUtils.copyDirectory(sourceFolder, destinationFolder, true); operationLog .info("Index successfully copies from '" + sourceFolder + "' to '" + destinationFolder + "'."); } catch (IOException ex) { operationLog.error("Couldn't copy '" + sourceFolder + "' to '" + destinationFolder + "'.", ex); } }
From source file:nl.knaw.dans.easy.sword2examples.SimpleDeposit.java
/** * Sends a bag to the easy-sword2 service and tracks its status until it is archived or failure is reported. * /*from w w w. j av a2s. com*/ * @param args * 0. collection URL (Col-IRI), 1. EASY user name, 2. EASY password, 3. zipped bag to send, */ public static void main(String[] args) throws Exception { if (args.length != 4) { System.err.println( "Usage: java nl.knaw.dans.easy.sword2examples.SimpleDeposit <Col-IRI> <EASY uid> <EASY passwd> <bag dirname>"); System.exit(1); } // Read command line arguments final IRI colIri = new IRI(args[0]); final String uid = args[1]; final String pw = args[2]; final String bagDirName = args[3]; File tempCopy = Common.copyToTarget(new File(bagDirName)); depositPackage(tempCopy, colIri, uid, pw); }