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:JTextAreaDemo.java

public static void main(String[] args) {
    JFrame frame = new JTextAreaDemo();
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }/*from  w w  w. j a va2  s  .  c o m*/
    });

    frame.pack();
    frame.setVisible(true);
}

From source file:mase.jbot.PresetCreator.java

public static void main(String[] args) throws Exception {
    if (args.length != 3) {
        System.out.println("PresetCreator [preset file] [controller file] [name tag]");
        System.exit(1);
    }//from w w w  .j  a va2 s  .  c  o m

    File preset = new File(args[0]);
    File cont = new File(args[1]);
    File tag = new File(args[2]);

    PersistentSolution sol = SolutionPersistence.readSolution(new FileInputStream(cont));
    GroupController contr = sol.getController();
    if (contr instanceof HomogeneousGroupController) {
        AgentController ac = contr.getAgentControllers(1)[0];
        File newFile = new File(preset.getAbsolutePath().replace(".conf", "") + "-" + tag + ".conf");
        FileUtils.copyFile(preset, newFile);
        NEATAgentController nac = (NEATAgentController) ac;
        double[] w = NEATSerializer.serializeToArray(nac.getNetwork());
        fillWeights(newFile, w);
    } else {
        AgentController[] acs = contr.getAgentControllers(0);
        for (int i = 0; i < acs.length; i++) {
            File newFile = new File(
                    preset.getAbsolutePath().replace(".conf", "") + "-" + tag + "-" + i + ".conf");
            FileUtils.copyFile(preset, newFile);
            NEATAgentController nac = (NEATAgentController) acs[i];
            double[] w = NEATSerializer.serializeToArray(nac.getNetwork());
            fillWeights(newFile, w);
        }
    }
}

From source file:FontPaint.java

public static void main(String[] args) {
    FontPanel starPanel = new FontPanel();

    JFrame f = new JFrame("Font");
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }//  w  w  w  .  j  av  a  2  s .  c om
    });

    f.getContentPane().add(starPanel, BorderLayout.CENTER);
    f.setSize(new Dimension(550, 200));
    f.setVisible(true);
}

From source file:JNLPTest.java

public static void main(String args[]) {
    JFrame frame = new JFrame();
    Container content = frame.getContentPane();
    JLabel label = new JLabel("Hello, JNLP");
    content.add(label, BorderLayout.CENTER);
    frame.setSize(200, 200);/*from www  .  j a  v a 2  s  .  c  o m*/
    frame.show();
    try {
        Thread.sleep(5000);
    } catch (InterruptedException ignored) {
    } finally {
        System.exit(0);
    }
}

From source file:Finger.java

public static void main(String[] args) {

    String hostname = "";
    String ulist = "";
    if (args.length == 0) {
        System.out.println("usage: finger host [user]");
        System.exit(1);
    }/*from   www.ja v  a 2 s  .c  o  m*/
    if (args.length >= 2)
        for (int i = 1; i < args.length; i++)
            ulist += args[i] + " ";
    hostname = args[0];
    Finger worker = new Finger();
    try {
        System.out.println(worker.finger(hostname, ulist.trim()));
    } catch (Exception e) {
        System.out.println(e);
    }
}

From source file:com.github.joemcintyre.pdffinish.Main.java

/**
 * Program entry point./*  w  ww.j  av a 2 s.co  m*/
 * @param args Command line arguments.
 */
public static void main(String args[]) {
    int exitCode = 0;

    try {
        exitCode = invoke(args);
    } catch (Exception e) {
        System.out.println("Uncaught exception " + e);
        e.printStackTrace();
        exitCode = GENERAL_ERROR;
    }

    System.exit(exitCode);
}

From source file:HelloInJapanese.java

public static void main(String argv[]) {

    HelloInJapanese japanesePanel = new HelloInJapanese(helloInJapanese);

    frame = new JFrame("Hello in Japanese");
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }/*from   w  w w .  jav  a  2  s.  c  o m*/
    });
    frame.getContentPane().add("Center", japanesePanel);
    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    Pattern pattern = null;/* www  .j a va2  s. c o m*/
    Matcher matcher = null;

    Console console = System.console();
    while (true) {
        try {
            pattern = Pattern.compile(console.readLine("%nEnter your regex: "));

            matcher = pattern.matcher(console.readLine("Enter input string to search: "));
        } catch (PatternSyntaxException pse) {
            console.format("There is a problem with the regular expression!%n");
            console.format("The pattern in question is: %s%n", pse.getPattern());
            console.format("The description is: %s%n", pse.getDescription());
            console.format("The message is: %s%n", pse.getMessage());
            console.format("The index is: %s%n", pse.getIndex());
            System.exit(0);
        }
        boolean found = false;
        while (matcher.find()) {
            console.format("I found the text \"%s\" starting at " + "index %d and ending at index %d.%n",
                    matcher.group(), matcher.start(), matcher.end());
            found = true;
        }
        if (!found) {
            console.format("No match found.%n");
        }
    }
}

From source file:com.springsource.samples.resttemplate.Driver.java

public static void main(String[] args) {
    if (args.length < 2) {
        System.out.println("Usage: java " + Driver.class.getName() + " [Flickr API key] [search term]");
        System.exit(-1);
    }//w  w w.j  a  v a 2  s .c  o  m
    String apiKey = args[0];
    String searchTerm = args[1];

    ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml",
            Driver.class);
    FlickrClient client = (FlickrClient) applicationContext.getBean("flickrClient", FlickrClient.class);
    client.doIt(apiKey, searchTerm);
}

From source file:Main.java

public static void main(String[] argv) {
    JFrame f = new JFrame();
    f.setSize(400, 300);// w  ww  .j a  va  2 s . c om
    Polygon p = new Polygon();
    p.addPoint(10, 10);
    p.addPoint(100, 300);
    p.addPoint(300, 300);
    p.addPoint(10, 10);

    PolygonButton btn = new PolygonButton(p, "button");
    f.getContentPane().add(btn);
    WindowListener wndCloser = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    f.addWindowListener(wndCloser);
    f.setVisible(true);
}