List of usage examples for java.lang System exit
public static void exit(int status)
From source file:PropertyTable.java
/** This main method allows the class to be demonstrated standalone */ public static void main(String[] args) { // Specify the name of the class as a command-line argument Class beanClass = null;//ww w. java2s .c o m try { // Use reflection to get the Class from the classname beanClass = Class.forName("javax.swing.JLabel"); } catch (Exception e) { // Report errors System.out.println("Can't find specified class: " + e.getMessage()); System.out.println("Usage: java TableDemo <JavaBean class name>"); System.exit(0); } // Create a table to display the properties of the specified class JTable table = new PropertyTable(beanClass); // Then put the table in a scrolling window, put the scrolling // window into a frame, and pop it all up on to the screen JScrollPane scrollpane = new JScrollPane(table); JFrame frame = new JFrame("Properties of JavaBean: "); frame.getContentPane().add(scrollpane); frame.setSize(500, 400); frame.setVisible(true); }
From source file:org.mzd.shap.spring.cli.Index.java
public static void main(String[] args) { if (args.length != 0) { System.out.println(USAGE_MSG); System.exit(1); }/* w w w . ja v a 2 s. com*/ try { ApplicationContext ctx = new ClassPathXmlApplicationContext("datasource-context.xml", "orm-massindex-context.xml"); SessionFactory sessionFactory = (SessionFactory) ctx.getBean("sessionFactory"); Session session = sessionFactory.openSession(); System.out.println(BEGIN_MSG); LOGGER.info(BEGIN_MSG); // Index single-threaded. Appear to have problems with collections. Search.getFullTextSession(session).createIndexer().batchSizeToLoadObjects(30) .threadsForSubsequentFetching(4).threadsToLoadObjects(2).cacheMode(CacheMode.NORMAL) .optimizeOnFinish(true).startAndWait(); //LOGGER.debug(Reporting.reportQueryCacheStatistics(sessionFactory)); //LOGGER.debug(Reporting.reportSecondLevleCacheStatistics(sessionFactory)); System.out.println(FINISH_MSG); LOGGER.info(FINISH_MSG); System.exit(0); } catch (Exception ex) { System.err.println(ERROR_MSG + " [" + ex.getMessage() + "]"); LOGGER.debug(ERROR_MSG, ex); } }
From source file:ShowHTMLViews.java
public static void main(String[] args) { try {/*from www.j a v a 2s . c o m*/ UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception evt) { } try { JFrame f = new JFrame("HTML Document View Structure"); final JEditorPane ep = new JEditorPane(args[0]); ep.setEditable(false); f.getContentPane().add(new JScrollPane(ep)); f.setSize(400, 300); f.setVisible(true); ep.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("page")) { System.out.println("Document:\n"); HTMLDocDisplay.displayModel(ep, System.out); System.out.println("\n\nViews:\n"); HTMLViewDisplayer.displayViews(ep, System.out); } } }); } catch (Exception e) { System.out.println(e); System.exit(1); } }
From source file:org.openscore.lang.tools.verifier.VerifierMain.java
public static void main(String[] args) { String repositoryPath = args[0]; Validate.notNull(repositoryPath, "You must pass a path to your repository"); repositoryPath = FilenameUtils.separatorsToSystem(repositoryPath); Validate.isTrue(new File(repositoryPath).isDirectory(), "Directory path argument \'" + repositoryPath + "\' does not lead to a directory"); ApplicationContext context = new AnnotationConfigApplicationContext(VerifierSpringConfiguration.class); SlangContentVerifier slangContentVerifier = context.getBean(SlangContentVerifier.class); try {/*w w w . j av a2 s. c o m*/ int numberOfValidSlangFiles = slangContentVerifier.verifyAllSlangFilesInDirAreValid(repositoryPath); System.out.println("SUCCESS: Found " + numberOfValidSlangFiles + " slang files under directory: \"" + repositoryPath + "\" and all are valid."); System.exit(0); } catch (Exception e) { System.out.println(e.getMessage() + "\n\nFAILURE: Validation of slang files under directory: \"" + repositoryPath + "\" failed."); // TODO - do we want to throw exception or exit with 1? System.exit(1); } }
From source file:jp.tricreo.codegenerator.Application.java
/** * ?? * * @param args */ public static void main(String[] args) { System.exit(new Application().run(args)); }
From source file:de.topobyte.osm4j.xml.dynsax.test.TestReadIteratorBz.java
public static void main(String[] args) throws ParserConfigurationException, SAXException, IOException { if (args.length != 1) { System.out.println("usage: " + TestReadIteratorBz.class.getSimpleName() + " <input osm xml bz>"); System.exit(1); }//from ww w. j ava 2s .c o m String pathInput = args[0]; TestReadIteratorBz test = new TestReadIteratorBz(); InputStream cinput = new FileInputStream(pathInput); InputStream input = new BZip2CompressorInputStream(cinput, true); OsmXmlIterator iterator = new OsmXmlIterator(input, false); while (iterator.hasNext()) { EntityContainer container = iterator.next(); if (container.getType() == EntityType.Node) { test.handle((OsmNode) container.getEntity()); } else if (container.getType() == EntityType.Way) { test.handle((OsmWay) container.getEntity()); } else if (container.getType() == EntityType.Relation) { test.handle((OsmRelation) container.getEntity()); } } }
From source file:com.insonix.cxf.client.PersonServiceClient.java
@SuppressWarnings("resource") public static void main(String args[]) throws Exception { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( new String[] { "cxf-servlet.xml" }); PersonService personService = (PersonService) context.getBean("personClient"); Person person = personService.getPerson(1); System.out.println("Response: " + person.getName()); System.exit(0); }
From source file:com.opengamma.integration.tool.portfolio.PortfolioLoaderTool.java
/** * Main method to run the tool.//w ww . ja v a2s . c o m * * @param args the arguments, not null */ public static void main(String[] args) { //CSIGNORE new PortfolioLoaderTool().initAndRun(args, ToolContext.class); System.exit(0); }
From source file:examples.finger.java
public static final void main(String[] args) { boolean longOutput = false; int arg = 0, index; String handle, host;/* ww w. j a va 2 s . c om*/ FingerClient finger; InetAddress address = null; // Get flags. If an invalid flag is present, exit with usage message. while (arg < args.length && args[arg].startsWith("-")) { if (args[arg].equals("-l")) longOutput = true; else { System.err.println("usage: finger [-l] [[[handle][@<server>]] ...]"); System.exit(1); } ++arg; } finger = new FingerClient(); // We want to timeout if a response takes longer than 60 seconds finger.setDefaultTimeout(60000); if (arg >= args.length) { // Finger local host try { address = InetAddress.getLocalHost(); } catch (UnknownHostException e) { System.err.println("Error unknown host: " + e.getMessage()); System.exit(1); } try { finger.connect(address); System.out.print(finger.query(longOutput)); finger.disconnect(); } catch (IOException e) { System.err.println("Error I/O exception: " + e.getMessage()); System.exit(1); } return; } // Finger each argument while (arg < args.length) { index = args[arg].lastIndexOf("@"); if (index == -1) { handle = args[arg]; try { address = InetAddress.getLocalHost(); } catch (UnknownHostException e) { System.err.println("Error unknown host: " + e.getMessage()); System.exit(1); } } else { handle = args[arg].substring(0, index); host = args[arg].substring(index + 1); try { address = InetAddress.getByName(host); } catch (UnknownHostException e) { System.err.println("Error unknown host: " + e.getMessage()); System.exit(1); } } System.out.println("[" + address.getHostName() + "]"); try { finger.connect(address); System.out.print(finger.query(longOutput, handle)); finger.disconnect(); } catch (IOException e) { System.err.println("Error I/O exception: " + e.getMessage()); System.exit(1); } ++arg; if (arg != args.length) System.out.print("\n"); } }