Example usage for java.lang System exit

List of usage examples for java.lang System exit

Introduction

In this page you can find the example usage for java.lang System exit.

Prototype

public static void exit(int status) 

Source Link

Document

Terminates the currently running Java Virtual Machine.

Usage

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setUndecorated(true);// w ww. ja v  a 2  s .  c  o  m
    frame.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            point.x = e.getX();
            point.y = e.getY();
        }
    });
    frame.addMouseMotionListener(new MouseMotionAdapter() {
        public void mouseDragged(MouseEvent e) {
            Point p = frame.getLocation();
            frame.setLocation(p.x + e.getX() - point.x, p.y + e.getY() - point.y);
        }
    });

    frame.setSize(300, 300);
    frame.setLocation(200, 200);
    frame.setLayout(new BorderLayout());

    frame.getContentPane().add(new JLabel("Drag to move", JLabel.CENTER), BorderLayout.CENTER);

    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu("Menu");
    menuBar.add(menu);
    JMenuItem item = new JMenuItem("Exit");
    item.addActionListener(e -> System.exit(0));
    menu.add(item);
    frame.setJMenuBar(menuBar);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setSize(300, 200);/*from   w w w. j  av a2 s .c o m*/
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });

    Container contentPane = frame.getContentPane();
    contentPane.add(new Main());

    frame.setVisible(true);
}

From source file:MappingContentHandler.java

static public void main(String[] arg) {
    try {/*from  w w  w  . j  a  v a 2 s.com*/
        SAXParserFactory spf = SAXParserFactory.newInstance();
        SAXParser parser = spf.newSAXParser();
        XMLReader reader = parser.getXMLReader();
        reader.setErrorHandler(new MyErrorHandler());
        MyTextHandler duper = new MyTextHandler();
        reader.setContentHandler(duper);
        InputSource is = new InputSource("person.xml");
        reader.parse(is);
    } catch (SAXException e) {
        System.out.println(e);
    } catch (ParserConfigurationException e) {
        System.err.println(e);
        System.exit(1);
    } catch (IOException e) {
        System.err.println(e);
        System.exit(1);
    }
}

From source file:com.fileanalyzer.main.Main.java

public static void main(String[] args) throws IOException {
    FileAnalyzer fl = null;/*  w w w . j a  va  2 s .  c o m*/
    try {
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("spring.xml");
        Configuration conf = (Configuration) ctx.getBean("configuration");
        fl = (FileAnalyzer) ctx.getBean("fileAnalyzer");
        if (args.length == 3 && args[1].equalsIgnoreCase("s")) {
            log.info("Added file id: " + fl.analizeString(args[0], args[2]));
        } else if (args.length == 2 && args[1].equalsIgnoreCase("a")) {
            fl.analizeFile(args[0], true);
        } else if (args.length == 1)
            fl.analizeFile(args[0], false);
        else {
            log.info(conf.getWrongParams());
            Thread.sleep(3000);
            System.exit(1);
        }
        log.info("Press any key to exit...");
        System.in.read();
    } catch (Exception ex) {
        ex.printStackTrace();
    } finally {
        if (fl != null) {
            fl.shutDown();
        }
        System.exit(0);
    }
}

From source file:demo.hw.server.SpringServer.java

public static void main(String args[]) throws Exception {
    new SpringServer();
    System.out.println("Server ready...");

    Thread.sleep(5 * 60 * 1000);/*from w ww .j a  v a2s . co  m*/
    System.out.println("Server exiting");
    System.exit(0);
}

From source file:TimerTest.java

public static void main(String[] args) {
    ActionListener listener = new TimePrinter();

    // construct a timer that calls the listener
    // once every 10 seconds
    Timer t = new Timer(10000, listener);
    t.start();//w  w  w  .jav  a2 s . co  m

    JOptionPane.showMessageDialog(null, "Quit program?");
    System.exit(0);
}

From source file:org.apache.isis.example.wrj.todoitem.ToDoItemSpringClient.java

public static void main(String args[]) throws Exception {
    // Initialize the spring context and fetch our test client
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
            new String[] { "classpath:client-applicationContext.xml" });
    ToDoItemTester client = (ToDoItemTester) context.getBean("tester");

    client.testService();/*from   w  ww.  j a  v  a  2  s  .com*/
    System.exit(0);
}

From source file:com.atlassian.clover.CloverInstr.java

public static void main(String[] args) {
    System.exit(mainImpl(args));
}

From source file:com.jmstoolkit.pipeline.Main.java

/**
 *
 * @param args/*w ww.  java2s .c o  m*/
 */
public static void main(final String[] args) {
    try {
        Settings.loadSystemSettings("jndi.properties");
        Settings.loadSystemSettings("app.properties");
    } catch (JTKException ex) {
        System.out.println("Failed to load application settings");
        System.out.println(JTKException.formatException(ex));
        System.exit(1);
    }

    final ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(new String[] {
            "/infrastructure-context.xml", "/mdb-context.xml", "/jmx-context.xml", "/logging-context.xml" });
    applicationContext.start();

    final DefaultMessageListenerContainer dmlc = (DefaultMessageListenerContainer) applicationContext
            .getBean("listenerContainer");
    if (dmlc != null) {
        dmlc.start();
        final Pipeline pipeline = (Pipeline) applicationContext.getBean("pipelineService");
        // enable access to the original application context
        pipeline.setApplicationContext(applicationContext);

        // Insure that the Pipeline loads configuration files AFTER
        // the listenerContainer is running.
        while (!dmlc.isRunning()) {
            try {
                Thread.sleep(100);
            } catch (InterruptedException ex) {
            }
        }
        pipeline.loadPlugins();
        pipeline.sendProperties();
        while (true) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException ex) {
            }
        }
    }
}

From source file:demo.spring.client.Client.java

public static void main(String args[]) throws Exception {
    // START SNIPPET: client
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
            new String[] { "client-beans.xml" });

    HelloWorld client = (HelloWorld) context.getBean("client");

    String response = client.sayHi("Joe");
    System.out.println("Response: " + response);
    System.exit(0);
    // END SNIPPET: client
}