List of usage examples for java.lang System exit
public static void exit(int status)
From source file:myproject.HelloWorld.java
/** * Main method./*from w ww . j a v a 2s. com*/ * * @param args Not used */ public static void main(String[] args) { String empty = null; Context context = new DefaultContext(); ConsoleLogger consoleLogger = new ConsoleLogger(Logger.LEVEL_INFO, "console"); consoleLogger.info("great it works"); if (StringUtils.isEmpty(empty)) { System.exit(0); } System.exit(1); }
From source file:GridBagWithWeight.java
public static void main(String[] args) { JFrame f = new JFrame("Demonstrates the use of fill constraints"); JPanel p = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(2, 2, 2, 2); c.weighty = 1.0;//from w ww .j a v a 2 s .c o m c.weightx = 1.0; c.gridx = 0; c.gridy = 0; c.gridheight = 2; c.fill = GridBagConstraints.BOTH; // Use both horizontal & vertical p.add(new JButton("Java"), c); c.gridx = 1; c.gridheight = 1; c.gridwidth = 2; c.fill = GridBagConstraints.HORIZONTAL; // Horizontal only p.add(new JButton("Source"), c); c.gridy = 1; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; // Remember to reset to none p.add(new JButton("and"), c); c.gridx = 2; c.fill = GridBagConstraints.VERTICAL; // Vertical only 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:org.dcache.xdr.SpringRunner.java
public static void main(String[] args) throws IOException { if (args.length != 1) { System.err.println("Usage: SpringRunner <config>"); System.exit(1); }/*from w w w . j a v a 2 s . c om*/ try { ApplicationContext context = new FileSystemXmlApplicationContext(args[0]); OncRpcSvc service = (OncRpcSvc) context.getBean("oncrpcsvc"); service.start(); System.in.read(); } catch (BeansException e) { System.err.println("Spring: " + e.getMessage()); System.exit(1); } }
From source file:test.SomeMainClass.java
public static void main(String[] args) throws Exception { Configuration cfg = new Configuration(); cfg.size();/*from w w w.j av a2s . co m*/ System.out.println("*** New Config is ***" + dumpConfiguration(cfg).toString()); System.getProperties().put("org.springframework.data.hadoop.jar.cfg", cfg); System.getProperties().put("org.springframework.data.hadoop.jar.args", args); System.setProperty("org.springframework.data.jar.exit.pre", "true"); try { System.exit(1); } catch (Throwable th) { System.getProperties().put("org.springframework.data.jar.exit.exception", th); } }
From source file:com.opengamma.integration.viewer.status.ViewStatusTool.java
/** * Main methog to run the tool./*from w w w . j ava 2 s.co m*/ * * @param args the arguments, not null */ public static void main(String[] args) { //CSIGNORE new ViewStatusTool().initAndRun(args, ToolContext.class); System.exit(0); }
From source file:org.transitappliance.loader.LoaderFrontEnd.java
/** * The main CLI of the program. Just loads the config file and spins up Spring. * @param args The command line arguments. Uses varargs so this can be called from a script *///from w ww .java 2 s. c o m public static void main(String... args) { // benchmarking long startTime = System.currentTimeMillis(); long totalTime; // Modeled after the main method in OTP Graph Builder // arg checking if (args.length == 0) { System.out.println("usage: loader config.xml"); System.exit(1); } System.out.println("Transit Appliance Stop Loader"); // Load Spring GenericApplicationContext ctx = new GenericApplicationContext(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(ctx); // Load config file for this agency and database adapter for (String file : args) reader.loadBeanDefinitions(new FileSystemResource(file)); // get the loader, config'd for this agency TransitStopLoader loader = (TransitStopLoader) ctx.getBean("transitStopLoader"); loader.loadStops(); }
From source file:DemoGetGeneratedKeysMySQL.java
public static void main(String[] args) throws Exception { Connection conn = getConnection(); Statement stmt = null;//from w w w . ja va 2s .c o m ResultSet rs = null; try { conn = getConnection(); stmt = conn.createStatement(); stmt.executeUpdate("insert into animals_table (name) values('newName')"); rs = stmt.getGeneratedKeys(); while (rs.next()) { ResultSetMetaData rsMetaData = rs.getMetaData(); int columnCount = rsMetaData.getColumnCount(); for (int i = 1; i <= columnCount; i++) { String key = rs.getString(i); System.out.println("key " + i + " is " + key); } } } catch (Exception e) { e.printStackTrace(); System.exit(1); } finally { try { rs.close(); stmt.close(); conn.close(); } catch (SQLException e) { e.printStackTrace(); } } }
From source file:GradientPaintEllipse.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 o m*/ }); JApplet applet = new GradientPaintEllipse(); f.getContentPane().add("Center", applet); applet.init(); f.pack(); f.setSize(new Dimension(300, 300)); f.show(); }
From source file:nl.knaw.dans.easy.sword2examples.ContinuedDeposit.java
public static void main(String[] args) throws Exception { if (args.length != 5) { System.err.println(//from ww w .j a v a2 s . c om "Usage: java nl.knaw.dans.easy.sword2examples.ContinuedDeposit <Col-IRI> <EASY uid> <EASY passwd> <chunk size> <bag dirname>"); System.exit(1); } // 0. Read command line arguments final IRI colIri = new IRI(args[0]); final String uid = args[1]; final String pw = args[2]; final int chunkSize = Integer.parseInt(args[3]); final String bagFileName = args[4]; depositPackage(new File(bagFileName), colIri, uid, pw, chunkSize); }
From source file:dk.qabi.imapfs.IMAPMount.java
public static void main(String[] args) throws MessagingException, MalformedURLException { if (args.length < 2) { System.out.println("[Error]: Must specify a mounting point"); System.out.println();/*from w w w.j a v a 2 s . c o m*/ System.out.println("[Usage]: imapfsmnt <mounting point>"); System.exit(-1); } final String urlSpec = args[0]; final URL url = new URL(null, urlSpec, new IMAPStreamHandler()); final String mountpoint = args[1]; String[] fs_args = new String[4]; fs_args[0] = "-f"; fs_args[1] = "-s"; fs_args[2] = mountpoint; fs_args[3] = "-ovolname=" + url.getHost() + ",fssubtype=7"; Filesystem imapfs = new LoggingFilesystem(new IMAPFileSystem(url), LogFactory.getLog("dk.qabi.imapfs")); File m = new File(mountpoint); if (!m.exists()) m.mkdirs(); try { FuseMount.mount(fs_args, imapfs); } catch (Exception e) { e.printStackTrace(); } }