List of usage examples for java.lang System exit
public static void exit(int status)
From source file:TestCreateConnectionWithProperties_MySQL.java
public static void main(String[] args) { Connection conn = null;//from w w w. j a v a 2 s . c o m try { // get connection to an Oracle database conn = getConnection(); System.out.println("conn=" + conn); } catch (Exception e) { // handle the exception e.printStackTrace(); System.exit(1); } finally { // release database resources try { conn.close(); } catch (Exception ignore) { } } }
From source file:com.opengamma.integration.tool.config.ConfigImportExportTool.java
/** * Main method to run the tool./* w w w .j a v a 2 s . c o m*/ */ public static void main(String[] args) { // CSIGNORE new ConfigImportExportTool().initAndRun(args, ToolContext.class); System.exit(0); }
From source file:DemoResultSetOracle.java
public static void main(String[] args) { Connection conn = null;//from w w w .ja v a 2 s. com Statement stmt = null; ResultSet rs = null; try { conn = getConnection(); System.out.println("conn=" + conn); // prepare query String query = "select id, name, age from employees"; // create a statement stmt = conn.createStatement(); // execute query and return result as a ResultSet rs = stmt.executeQuery(query); // extract data from the ResultSet while (rs.next()) { String id = rs.getString(1); String name = rs.getString(2); int age = rs.getInt(3); System.out.println("id=" + id); System.out.println("name=" + name); System.out.println("age=" + age); System.out.println("---------------"); } } catch (Exception e) { e.printStackTrace(); System.exit(1); } finally { // release database resources try { rs.close(); stmt.close(); conn.close(); } catch (SQLException e) { e.printStackTrace(); } } }
From source file:kilim.tools.FlowAnalyzer.java
public static void main(String[] args) throws Exception { if (args.length == 0) { log.error("Usage <class name | jar file name> [methodName]"); System.exit(1); }//from w w w . j a v a2 s . c o m String name = args[0]; if (name.endsWith(".jar")) { analyzeJar(name, Detector.DEFAULT); } else { analyzeClass(name, Detector.DEFAULT); } }
From source file:DocumentIteratorExample.java
public static void main(String args[]) throws Exception { URL url = new URL("http://www.java2s.com"); URLConnection connection = url.openConnection(); InputStream is = connection.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); HTMLEditorKit htmlKit = new HTMLEditorKit(); HTMLDocument htmlDoc = (HTMLDocument) htmlKit.createDefaultDocument(); HTMLEditorKit.Parser parser = new ParserDelegator(); HTMLEditorKit.ParserCallback callback = htmlDoc.getReader(0); parser.parse(br, callback, true);/*from www . j a va 2 s.c om*/ for (HTMLDocument.Iterator iterator = htmlDoc.getIterator(HTML.Tag.A); iterator.isValid(); iterator .next()) { AttributeSet attributes = iterator.getAttributes(); String srcString = (String) attributes.getAttribute(HTML.Attribute.HREF); System.out.print(srcString); int startOffset = iterator.getStartOffset(); int endOffset = iterator.getEndOffset(); int length = endOffset - startOffset; String text = htmlDoc.getText(startOffset, length); System.out.println(" - " + text); } System.exit(0); }
From source file:Main.java
public static void main(String args[]) throws Exception { final ByteArrayOutputStream out = new ByteArrayOutputStream(); float sampleRate = 8000; int sampleSizeInBits = 8; int channels = 1; boolean signed = true; boolean bigEndian = true; final AudioFormat format = new AudioFormat(sampleRate, sampleSizeInBits, channels, signed, bigEndian); DataLine.Info info = new DataLine.Info(TargetDataLine.class, format); final TargetDataLine line = (TargetDataLine) AudioSystem.getLine(info); line.open(format);//w w w .j a v a 2 s . co m line.start(); Runnable runner = new Runnable() { int bufferSize = (int) format.getSampleRate() * format.getFrameSize(); byte buffer[] = new byte[bufferSize]; public void run() { try { int count = line.read(buffer, 0, buffer.length); if (count > 0) { out.write(buffer, 0, count); } out.close(); } catch (IOException e) { System.err.println("I/O problems: " + e); System.exit(-1); } } }; Thread captureThread = new Thread(runner); captureThread.start(); byte audio[] = out.toByteArray(); InputStream input = new ByteArrayInputStream(audio); final SourceDataLine line1 = (SourceDataLine) AudioSystem.getLine(info); final AudioInputStream ais = new AudioInputStream(input, format, audio.length / format.getFrameSize()); line1.open(format); line1.start(); runner = new Runnable() { int bufferSize = (int) format.getSampleRate() * format.getFrameSize(); byte buffer[] = new byte[bufferSize]; public void run() { try { int count; while ((count = ais.read(buffer, 0, buffer.length)) != -1) { if (count > 0) { line1.write(buffer, 0, count); } } line1.drain(); line1.close(); } catch (IOException e) { System.err.println("I/O problems: " + e); System.exit(-3); } } }; Thread playThread = new Thread(runner); playThread.start(); }
From source file:it.polimi.tower4clouds.data_analyzer.DAServer.java
public static void main(String[] args) { PropertiesConfiguration releaseProperties = null; try {/*from w w w . j ava 2s . c o m*/ releaseProperties = new PropertiesConfiguration("release.properties"); } catch (org.apache.commons.configuration.ConfigurationException e) { logger.error("Internal error", e); System.exit(1); } APP_NAME = releaseProperties.getString("application.name"); APP_FILE_NAME = releaseProperties.getString("dist.file.name"); APP_VERSION = releaseProperties.getString("release.version"); try { DAConfig config = new DAConfig(args, APP_FILE_NAME); if (config.isHelp()) { System.out.println(config.usage); } else if (config.isVersion()) { System.out.println("Version: " + APP_VERSION); } else { String[] rspArgs = new String[1]; rspArgs[0] = "da.properties"; System.setProperty(InputDataUnmarshaller.INPUT_DATA_UNMARSHALLER_IMPL_PROPERTY_NAME, DAInputDataUnmarshaller.class.getName()); System.setProperty(OutputDataMarshaller.OUTPUT_DATA_MARSHALLER_IMPL_PROPERTY_NAME, DAOutputDataMarshaller.class.getName()); System.setProperty("log4j.configuration", "log4j.properties"); // System.setProperty("rsp_server.static_resources.path", // config.getKBFolder()); NOT USED BY RSP!!! System.setProperty("csparql_server.port", Integer.toString(config.getPort())); logger.info("{} {}", APP_NAME, APP_VERSION); rsp_services_csparql_server.main(rspArgs); } } catch (ConfigurationException e) { logger.error("Configuration problem: " + e.getMessage()); logger.error("Run \"" + APP_FILE_NAME + " -help\" for help"); System.exit(1); } catch (Exception e) { logger.error("Unknown error", e); } }
From source file:cognition.pipeline.Main.java
/** * Entry point of Cognition-DNC/*from w ww.ja v a 2 s .c om*/ */ public static void main(String[] args) { if (requiresHelp(args)) { CommandHelper.printHelp(); System.exit(0); } String path = "file:" + getCurrentFolder() + File.separator + "config" + File.separator + "applicationContext.xml"; logger.info("Loading context from " + path); context = new ClassPathXmlApplicationContext(path); Options options = getOptions(); CommandLineParser parser = new GnuParser(); Runtime.getRuntime().addShutdownHook(getShutDownBehaviour()); try { CommandLine cmd = parser.parse(options, args); processCommands(cmd); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.ala.hbase.EmblemLoader.java
/** * @param args//from ww w.ja v a2s.c o m */ public static void main(String[] args) throws Exception { ApplicationContext context = SpringUtils.getContext(); EmblemLoader l = context.getBean(EmblemLoader.class); l.load(); System.exit(0); }
From source file:DoAudioCapture.java
public static void main(String[] args) { Location2Location capture; CaptureDeviceInfo audioDevice;//from ww w. ja v a2 s.co m MediaLocator audioLocation; MediaLocator destination; audioDevice = CaptureDeviceManager.getDevice("DirectSoundCapture"); audioLocation = audioDevice.getLocator(); Format[] format = new Format[1]; format[0] = new AudioFormat(AudioFormat.LINEAR); ContentDescriptor container = new ContentDescriptor(FileTypeDescriptor.WAVE); destination = new MediaLocator("file://d:\\jmf\\book\\media\\capturedSound.wav"); capture = new Location2Location(audioLocation, destination, format, container, 1.0); System.out.println("Started recording..."); capture.setStopTime(new Time(10.0)); int waited = capture.transfer(35000); int state = capture.getState(); System.out.println("Waited " + waited + " milliseconds. State now " + state); waited /= 1000; while (state != Location2Location.FINISHED && state != Location2Location.FAILED) { try { Thread.sleep(10000); } catch (InterruptedException ie) { } System.out.println("Waited another 10 seconds, state = " + capture.getState()); waited += 10; } System.out.println("Waited a total of " + waited + " seconds"); System.exit(0); }