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

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

    Properties props = new Properties();

    String host = "yourHost.edu";
    String username = "userName";
    String password = "mypassword";
    String provider = "pop3";

    Session session = Session.getDefaultInstance(props, null);
    Store store = session.getStore(provider);
    store.connect(host, username, password);

    Folder inbox = store.getFolder("INBOX");
    if (inbox == null) {
        System.out.println("No INBOX");
        System.exit(1);
    }/*from   ww  w. jav a 2  s.co  m*/
    inbox.open(Folder.READ_ONLY);

    Message[] messages = inbox.getMessages();
    for (int i = 0; i < messages.length; i++) {
        System.out.println("Message " + (i + 1));
        messages[i].writeTo(System.out);
    }
    inbox.close(false);
    store.close();
}

From source file:Main.java

public static void main(String[] args) throws InterruptedException {
    JFrame frame = new JFrame();
    frame.add(new JLabel("Minimize demo"));
    frame.pack();/*from   www .  j  a v  a 2  s.  co  m*/

    // Show the frame
    frame.setVisible(true);

    // Sleep for 5 seconds, then minimize
    Thread.sleep(5000);
    frame.setState(Frame.ICONIFIED);

    // Sleep for 5 seconds, then restore
    Thread.sleep(5000);
    frame.setState(Frame.NORMAL);

    // Sleep for 5 seconds, then kill window
    Thread.sleep(5000);
    frame.setVisible(false);
    frame.dispose();

    // Terminate test
    System.exit(0);
}

From source file:Test.java

public static void main(String[] args) {
    JFrame.setDefaultLookAndFeelDecorated(true);

    GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice graphicsDevice = graphicsEnvironment.getDefaultScreenDevice();

    if (!graphicsDevice.isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency.TRANSLUCENT)) {
        System.err.println("Translucency is not supported on this platform");
        System.exit(0);
    }/* w w w  . j a  va  2 s .com*/
    ApplicationWindow window = new ApplicationWindow();
    window.setOpacity(0.75f);
    window.setVisible(true);
}

From source file:Main.java

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

    Properties props = new Properties();

    String host = "yourserver.edu";
    String provider = "pop3";

    Session session = Session.getDefaultInstance(props, new MailAuthenticator());
    Store store = session.getStore(provider);
    store.connect(host, null, null);/*  w w w  .ja v a  2s.  co m*/

    Folder inbox = store.getFolder("INBOX");
    if (inbox == null) {
        System.out.println("No INBOX");
        System.exit(1);
    }
    inbox.open(Folder.READ_ONLY);

    Message[] messages = inbox.getMessages();
    for (int i = 0; i < messages.length; i++) {
        System.out.println("Message " + (i + 1));
        messages[i].writeTo(System.out);
    }
    inbox.close(false);
    store.close();
}

From source file:JavaWorldPrintExample3.java

public static void main(String[] args) {

    JavaWorldPrintExample3 example3 = new JavaWorldPrintExample3();
    System.exit(0);
}

From source file:com.kijes.ela.serial.ElaSerialApplication.java

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

From source file:AuthenticateNT.java

public static void main(String[] args) {
    try {//  w  w  w .j  av  a  2 s . co m
        LoginContext loginContext = new LoginContext("AuthenticateNT");
        loginContext.login();
        System.out.println("Login Successful");
        Subject subject = loginContext.getSubject();
        System.out.println(subject);
        Subject.doAs(subject, new WriteFileAction());
        loginContext.logout();
        System.exit(0);
    } catch (LoginException loginException) {
        loginException.printStackTrace();
        System.exit(-1);
    }
}

From source file:MappedChannelRead.java

public static void main(String args[]) {
    FileInputStream fIn;/* w  ww. j a  v  a 2s.c o  m*/
    FileChannel fChan;
    long fSize;
    MappedByteBuffer mBuf;

    try {
        fIn = new FileInputStream("test.txt");
        fChan = fIn.getChannel();
        fSize = fChan.size();
        mBuf = fChan.map(FileChannel.MapMode.READ_ONLY, 0, fSize);
        for (int i = 0; i < fSize; i++)
            System.out.print((char) mBuf.get());

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

From source file:XMLTreeView.java

public static void main(String args[]) {
    JFrame frame = new JFrame("XMLTreeView: [ games.xml ]");
    frame.setSize(400, 400);/*www  .  j av a  2s .c o  m*/

    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent ev) {
            System.exit(0);
        }
    });
    file = "games.xml";
    new XMLTreeView(frame);
}

From source file:MainClass.java

public static void main(String args[]) {
    RandomAccessFile randomAccessFile;
    FileChannel fileChannel;//from w  w w  .  j a va  2  s. c  o  m
    ByteBuffer byteBuffer;

    try {
        randomAccessFile = new RandomAccessFile("test.txt", "rw");
        fileChannel = randomAccessFile.getChannel();
        byteBuffer = fileChannel.map(FileChannel.MapMode.READ_WRITE, 0, 26);
        for (int i = 0; i < 10; i++)
            byteBuffer.put((byte) ('A' + i));
        fileChannel.close();
        randomAccessFile.close();
    } catch (IOException exc) {
        System.out.println(exc);
        System.exit(1);
    }
}