List of usage examples for java.lang System exit
public static void exit(int status)
From source file:ShapeMover.java
public static void main(String s[]) { Frame f = new Frame("ShapeMover"); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); }//from w w w .j a va 2 s . c om }); Applet applet = new ShapeMover(); f.add("Center", applet); applet.init(); f.pack(); f.setSize(new Dimension(550, 250)); f.show(); }
From source file:JustOneLock.java
public static void main(String[] args) throws Exception { JustOneLock ua = new JustOneLock("JustOneId"); if (ua.isAppActive()) { System.out.println("Already active."); System.exit(1); } else {//from w w w . j a va 2s. co m System.out.println("NOT already active."); } }
From source file:com.opengamma.integration.tool.portfolio.PortfolioCopyMoveTool.java
/** * Runs the tool.//ww w.j av a 2 s.c o m * * @param args empty arguments */ public static void main(String[] args) { // CSIGNORE boolean success = new PortfolioCopyMoveTool().initAndRun(args, IntegrationToolContext.class); System.exit(success ? 0 : 1); }
From source file:Main.java
public static void main(String[] args) throws Exception { if (!SystemTray.isSupported()) { return;//from w w w. ja v a2 s. c o m } SystemTray tray = SystemTray.getSystemTray(); Dimension size = tray.getTrayIconSize(); BufferedImage bi = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB); Graphics g = bi.getGraphics(); g.setColor(Color.blue); g.fillRect(0, 0, size.width, size.height); PopupMenu popup = new PopupMenu(); MenuItem miExit = new MenuItem("Exit"); ActionListener al; al = new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }; miExit.addActionListener(al); popup.add(miExit); TrayIcon ti = new TrayIcon(bi, "System Tray Demo #2"); ti.setPopupMenu(popup); al = new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println(e.getActionCommand()); } }; ti.setActionCommand("My Icon"); ti.addActionListener(al); MouseListener ml = new MouseListener() { public void mouseClicked(MouseEvent e) { System.out.println("Tray icon: Mouse clicked"); } public void mouseEntered(MouseEvent e) { System.out.println("Tray icon: Mouse entered"); } public void mouseExited(MouseEvent e) { System.out.println("Tray icon: Mouse exited"); } public void mousePressed(MouseEvent e) { System.out.println("Tray icon: Mouse pressed"); } public void mouseReleased(MouseEvent e) { System.out.println("Tray icon: Mouse released"); } }; ti.addMouseListener(ml); MouseMotionListener mml = new MouseMotionListener() { public void mouseDragged(MouseEvent e) { System.out.println("Tray icon: Mouse dragged"); } public void mouseMoved(MouseEvent e) { System.out.println("Tray icon: Mouse moved"); } }; ti.addMouseMotionListener(mml); Image image = ti.getImage(); tray.add(ti); }
From source file:org.copperengine.spring.SpringEngineStarter.java
/** * @param args//w w w . jav a 2 s. c o m */ public static void main(String[] args) { if (args.length == 0) { System.out.println("Usage: " + SpringEngineStarter.class.getName() + " <configLocations>"); System.exit(-2); } try { new FileSystemXmlApplicationContext(args); } catch (Exception e) { logger.error("Startup failed", e); System.exit(-1); } }
From source file:io.s4.util.AvroSchemaSupplementer.java
public static void main(String args[]) { if (args.length < 1) { System.err.println("No schema filename specified"); System.exit(1); }/*from w ww . ja va 2 s.com*/ String filename = args[0]; FileReader fr = null; BufferedReader br = null; InputStreamReader isr = null; try { if (filename == "-") { isr = new InputStreamReader(System.in); br = new BufferedReader(isr); } else { fr = new FileReader(filename); br = new BufferedReader(fr); } String inputLine = ""; StringBuffer jsonBuffer = new StringBuffer(); while ((inputLine = br.readLine()) != null) { jsonBuffer.append(inputLine); } JSONObject jsonRecord = new JSONObject(jsonBuffer.toString()); JSONObject keyPathElementSchema = new JSONObject(); keyPathElementSchema.put("name", "KeyPathElement"); keyPathElementSchema.put("type", "record"); JSONArray fieldsArray = new JSONArray(); JSONObject fieldRecord = new JSONObject(); fieldRecord.put("name", "index"); JSONArray typeArray = new JSONArray("[\"int\", \"null\"]"); fieldRecord.put("type", typeArray); fieldsArray.put(fieldRecord); fieldRecord = new JSONObject(); fieldRecord.put("name", "keyName"); typeArray = new JSONArray("[\"string\", \"null\"]"); fieldRecord.put("type", typeArray); fieldsArray.put(fieldRecord); keyPathElementSchema.put("fields", fieldsArray); JSONObject keyInfoSchema = new JSONObject(); keyInfoSchema.put("name", "KeyInfo"); keyInfoSchema.put("type", "record"); fieldsArray = new JSONArray(); fieldRecord = new JSONObject(); fieldRecord.put("name", "keyPath"); typeArray = new JSONArray("[\"string\", \"null\"]"); fieldRecord.put("type", typeArray); fieldsArray.put(fieldRecord); fieldRecord = new JSONObject(); fieldRecord.put("name", "fullKeyPath"); typeArray = new JSONArray("[\"string\", \"null\"]"); fieldRecord.put("type", typeArray); fieldsArray.put(fieldRecord); fieldRecord = new JSONObject(); fieldRecord.put("name", "keyPathElementList"); JSONObject typeRecord = new JSONObject(); typeRecord.put("type", "array"); typeRecord.put("items", keyPathElementSchema); fieldRecord.put("type", typeRecord); fieldsArray.put(fieldRecord); keyInfoSchema.put("fields", fieldsArray); JSONObject partitionInfoSchema = new JSONObject(); partitionInfoSchema.put("name", "PartitionInfo"); partitionInfoSchema.put("type", "record"); fieldsArray = new JSONArray(); fieldRecord = new JSONObject(); fieldRecord.put("name", "partitionId"); typeArray = new JSONArray("[\"int\", \"null\"]"); fieldRecord.put("type", typeArray); fieldsArray.put(fieldRecord); fieldRecord = new JSONObject(); fieldRecord.put("name", "compoundKey"); typeArray = new JSONArray("[\"string\", \"null\"]"); fieldRecord.put("type", typeArray); fieldsArray.put(fieldRecord); fieldRecord = new JSONObject(); fieldRecord.put("name", "compoundValue"); typeArray = new JSONArray("[\"string\", \"null\"]"); fieldRecord.put("type", typeArray); fieldsArray.put(fieldRecord); fieldRecord = new JSONObject(); fieldRecord.put("name", "keyInfoList"); typeRecord = new JSONObject(); typeRecord.put("type", "array"); typeRecord.put("items", keyInfoSchema); fieldRecord.put("type", typeRecord); fieldsArray.put(fieldRecord); partitionInfoSchema.put("fields", fieldsArray); fieldRecord = new JSONObject(); fieldRecord.put("name", "S4__PartitionInfo"); typeRecord = new JSONObject(); typeRecord.put("type", "array"); typeRecord.put("items", partitionInfoSchema); fieldRecord.put("type", typeRecord); fieldsArray = jsonRecord.getJSONArray("fields"); fieldsArray.put(fieldRecord); System.out.println(jsonRecord.toString(3)); } catch (Exception ioe) { throw new RuntimeException(ioe); } finally { if (br != null) try { br.close(); } catch (Exception e) { } if (isr != null) try { isr.close(); } catch (Exception e) { } if (fr != null) try { fr.close(); } catch (Exception e) { } } }
From source file:Main.java
public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame(); frame.setResizable(false);/*from w w w . j a v a 2 s.co m*/ removeButtons(frame); JPanel panel = new JPanel(new GridBagLayout()); JButton button = new JButton("Exit"); panel.add(button, new GridBagConstraints()); frame.getContentPane().add(panel); frame.setSize(400, 300); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); button.addActionListener(e -> System.exit(0)); }
From source file:hip.ch3.seqfile.writable.seqfile.SequenceFileStockWriter.java
public static void main(final String[] args) throws Exception { int res = ToolRunner.run(new Configuration(), new SequenceFileStockWriter(), args); System.exit(res); }
From source file:httpscheduler.HttpScheduler.java
/** * @param args the command line arguments * @throws java.lang.Exception/*from www.j a va 2 s . c o m*/ */ public static void main(String[] args) throws Exception { if (args.length != 2) { System.err.println("Invalid command line parameters for worker"); System.exit(-1); } int fixedExecutorSize = 4; //Creating fixed size executor ThreadPoolExecutor taskCommExecutor = new ThreadPoolExecutor(fixedExecutorSize, fixedExecutorSize, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); // Used for late binding JobMap jobMap = new JobMap(); // Set port number int port = Integer.parseInt(args[0]); // Set worker mode String mode = args[1].substring(2); // Set up the HTTP protocol processor HttpProcessor httpproc = HttpProcessorBuilder.create().add(new ResponseDate()) .add(new ResponseServer("Test/1.1")).add(new ResponseContent()).add(new ResponseConnControl()) .build(); // Set up request handlers UriHttpRequestHandlerMapper reqistry = new UriHttpRequestHandlerMapper(); // Different handlers for late binding and generic cases if (mode.equals("late")) reqistry.register("*", new LateBindingRequestHandler(taskCommExecutor, jobMap)); else reqistry.register("*", new GenericRequestHandler(taskCommExecutor, mode)); // Set up the HTTP service HttpService httpService = new HttpService(httpproc, reqistry); SSLServerSocketFactory sf = null; // create a thread to listen for possible client available connections Thread t; if (mode.equals("late")) t = new LateBindingRequestListenerThread(port, httpService, sf); else t = new GenericRequestListenerThread(port, httpService, sf); System.out.println("Request Listener Thread created"); t.setDaemon(false); t.start(); // main thread should wait for the listener to exit before shutdown the // task executor pool t.join(); // shutdown task executor pool and wait for any taskCommExecutor thread // still running taskCommExecutor.shutdown(); while (!taskCommExecutor.isTerminated()) { } System.out.println("Finished all task communication executor threads"); System.out.println("Finished all tasks"); }
From source file:FillRectPanel.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setTitle("FillRect"); frame.setSize(300, 200);/*from w ww . j a va 2 s. c om*/ frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); Container contentPane = frame.getContentPane(); contentPane.add(new FillRectPanel()); frame.show(); }