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

/**
 * @param args/*www.  ja v  a 2s .  co m*/
 */
public static void main(String[] args) {
    // TODO Auto-generated method stub

    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    InputStream is = cl.getResourceAsStream("com/sap/ca/aspose/license/Aspose.Total.Java.lic");
    //InputStream is = cl.getResourceAsStream("com/sap/ca/aspose/license/a.txt");
    if (is == null) {
        System.err.println("Error is is null");
        System.exit(1);

    }
    String s;
    try {
        s = IOUtils.toString(is);
        System.out.println(s);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

From source file:GenericServer.java

public static void main(String args[]) {
    int serverPort = 1234;
    try {/*from w  w  w  .  j  a v  a 2  s.c  o m*/
        ServerSocket server = new ServerSocket(serverPort);
        do {
            Socket client = server.accept();
            (new ServerThread(client)).start();
        } while (true);
    } catch (IOException ex) {
        System.exit(0);
    }
}

From source file:uk.ac.ebi.ep.parser.main.PDBeParser.java

public static void main(String args[]) throws Exception {

    String profile = "";

    if (args == null || args.length == 0) {
        System.out.println("Please provide required parameters");
        System.exit(0);
    }//from w w w . ja v a 2 s  .c o  m

    if (args.length == 1) {

        profile = args[0];

        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
        context.getEnvironment().setActiveProfiles(profile);
        context.scan("uk.ac.ebi.ep.data.dataconfig", "uk.ac.ebi.ep.parser.config");
        context.refresh();

        EnzymePortalPDBeParser pdbParser = context.getBean(EnzymePortalPDBeParser.class);

        pdbParser.updatePDBeData();
    }

}

From source file:HyperlinkTest.java

public static void main(String args[]) {
    JFrame frame = new JFrame();
    Container contentPane = frame.getContentPane();

    final JEditorPane ep = new JEditorPane();

    try {/*from  ww w  . j  av a2s .c  o m*/
        ep.setPage("http://www.java2s.com");
    } catch (IOException e) {
        System.err.println("Bad URL: " + e);
        System.exit(-1);
    }

    HyperlinkListener listener = new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                try {
                    ep.setPage(e.getURL());
                } catch (IOException ioe) {
                    System.err.println("Error loading: " + ioe);
                }
            }
        }
    };
    ep.addHyperlinkListener(listener);
    ep.setEditable(false);
    JScrollPane pane = new JScrollPane(ep);
    contentPane.add(pane, BorderLayout.CENTER);
    frame.setSize(640, 480);
    frame.show();
}

From source file:MainClass.java

public static void main(String args[]) {
    SynthLookAndFeel synth = new SynthLookAndFeel();
    try {/* w  w w  .  ja va  2  s . com*/
        Class aClass = MainClass.class;
        InputStream is = aClass.getResourceAsStream("config.xml");
        if (is == null) {
            System.err.println("Unable to find theme configuration");
            System.exit(-1);
        }
        synth.load(is, aClass);
    } catch (ParseException e) {
        System.err.println("Unable to load theme configuration");
        System.exit(-2);
    }
    try {
        UIManager.setLookAndFeel(synth);
    } catch (javax.swing.UnsupportedLookAndFeelException e) {
        System.err.println("Unable to change look and feel");
        System.exit(-3);
    }
    JFrame frame = new JFrame("Synth Sample");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JButton button = new JButton("Hello, Synth");
    frame.add(button, BorderLayout.CENTER);
    JTextField textField = new JTextField();
    frame.add(textField, BorderLayout.SOUTH);
    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:MappedChannelWrite.java

public static void main(String args[]) {
    RandomAccessFile fOut;/*  ww  w . j a  v  a 2 s.  c  o m*/
    FileChannel fChan;
    ByteBuffer mBuf;

    try {
        fOut = new RandomAccessFile("test.txt", "rw");
        fChan = fOut.getChannel();
        mBuf = fChan.map(FileChannel.MapMode.READ_WRITE, 0, 26);
        for (int i = 0; i < 26; i++)
            mBuf.put((byte) ('A' + i));

        fChan.close();
        fOut.close();
    } catch (IOException exc) {
        System.out.println(exc);
        System.exit(1);
    }
}

From source file:SimpleGridBag.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    JPanel p = new JPanel();

    p.setLayout(new GridBagLayout());
    p.add(new JButton("Java"));
    p.add(new JButton("Source"));
    p.add(new JButton("and"));
    p.add(new JButton("Support."));

    WindowListener wndCloser = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }//w w w .  j  a v a2 s.  co m
    };
    f.addWindowListener(wndCloser);

    f.getContentPane().add(p);
    f.setSize(600, 200);
    f.show();
}

From source file:uk.ac.ebi.ep.parser.main.PathwaysParser.java

public static void main(String args[]) throws Exception {
    String file = "";
    String profile = "";

    if (args == null || args.length == 0) {
        System.out.println("Please provide required parameters");
        System.exit(0);
    }//from   w  ww . ja va 2s  . c om

    if (args.length == 2) {

        profile = args[0];
        file = args[1];

        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
        context.getEnvironment().setActiveProfiles(profile);
        //context.scan("uk.ac.ebi.ep.data.dataconfig");
        context.scan("uk.ac.ebi.ep.data.dataconfig", "uk.ac.ebi.ep.parser.config");
        context.refresh();

        EnzymePortalPathwaysParser pathwaysParser = context.getBean(EnzymePortalPathwaysParser.class);

        pathwaysParser.parseReactomeFile(file);//Total time: 1:57:24.500s
    }

}

From source file:MetalModExample.java

public static void main(String[] args) {
    try {/* w ww .j  a va  2s . c  om*/
        UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
    } catch (Exception e) {
        System.err.println("Metal is not available on this platform?!");
        System.exit(1);
    }
    JComponent before = makeExamplePane();

    UIManager.put("ScrollBarUI", "MyMetalScrollBarUI");

    JComponent after = makeExamplePane();

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Container c = f.getContentPane();
    c.setLayout(new GridLayout(2, 1, 0, 1));
    c.add(before);
    c.add(after);
    f.setSize(450, 400);
    f.setVisible(true);
}

From source file:ShowConfigurations.java

public static void main(String[] args) {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice defaultScreen = ge.getDefaultScreenDevice();
    GraphicsConfiguration[] configurations = defaultScreen.getConfigurations();
    System.out.println("Default screen device: " + defaultScreen.getIDstring());
    for (int i = 0; i < configurations.length; i++) {
        System.out.println("  Configuration " + (i + 1));
        System.out.println("  " + configurations[i].getColorModel());
    }/*from   w w w.  j a  v  a  2s . co m*/
    System.exit(0);
}