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

public static void main(String args[]) {
    try {//from   ww  w . ja  v  a  2s  .c om
        System.setProperty("sen.home", "../Sen1221/senhome-ipadic");
        System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
        System.setProperty("org.apache.commons.logging.simplelog.defaultlog", "FATAL");

        if (args.length != 2) {
            System.err.println("usage: java StreamTaggerDemo <filename> <encoding>");
            System.exit(1);
        }
        BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(args[0]), args[1]));
        // String confPath = System.getProperty("sen.home")
        // + System.getProperty("file.separator") + "conf/sen.xml";
        // StreamTagger tagger = new StreamTagger((Reader) br, confPath);
        StreamTagger tagger = new StreamTagger((Reader) br);

        // BufferedReader is = new BufferedReader(System.in);

        while (tagger.hasNext()) {
            Token token = tagger.next();
            System.out.println(token.toString() + "\t(" + token.getBasicString() + ")" + "\t" + token.getPos()
                    + "(" + token.start() + "," + token.end() + "," + token.length() + ")\t"
                    + token.getReading() + "\t" + token.getPronunciation());
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:edu.umn.msi.tropix.proteomics.tools.DTAToMzXML.java

public static void main(final String[] args) throws Exception {
    if (args.length < 1) {
        usage();/*from w ww  .  jav a 2s .co m*/
        System.exit(0);
    }
    Collection<File> files = null;

    if (args[0].equals("-files")) {
        if (args.length < 2) {
            out.println("No files specified.");
            usage();
            exit(-1);
        } else {
            files = new ArrayList<File>(args.length - 1);
            for (int i = 1; i < args.length; i++) {
                files.add(new File(args[i]));
            }
        }
    } else if (args[0].equals("-directory")) {
        File directory;
        if (args.length < 2) {
            directory = new File(System.getProperty("user.dir"));
        } else {
            directory = new File(args[2]);
        }
        files = FileUtilsFactory.getInstance().listFiles(directory, new String[] { "dta" }, false);
    } else {
        usage();
        exit(-1);
    }

    final InMemoryDTAListImpl dtaList = new InMemoryDTAListImpl();
    File firstFile = null;
    if (files.size() == 0) {
        out.println("No files found.");
        exit(-1);
    } else {
        firstFile = files.iterator().next();
    }
    for (final File file : files) {
        dtaList.add(FileUtils.readFileToByteArray(file), file.getName());
    }

    final DTAToMzXMLConverter dtaToMzXMLConverter = new DTAToMzXMLConverterImpl();
    final MzXML mzxml = dtaToMzXMLConverter.dtaToMzXML(dtaList, null);
    final String mzxmlName = firstFile.getName().substring(0, firstFile.getName().indexOf(".")) + ".mzXML";
    new MzXMLUtility().serialize(mzxml, mzxmlName);
}

From source file:demo.wssec.server.Server.java

public static void main(String args[]) throws Exception {
    System.out.println();//from   w w w.  j a v a2s.c om
    new Server();
    System.out.println("Server ready...");

    Thread.sleep(5 * 60 * 1000);
    System.out.println("Server exiting");
    System.exit(0);
}

From source file:com.kinesis.datavis.utils.DeleteSampleResources.java

public static void main(String[] args) {
    if (args.length != 4) {
        System.err.println("Usage: " + DeleteSampleResources.class.getSimpleName()
                + " <application name> <stream name> <DynamoDB table name> <region>");
        System.exit(1);
    }/*from w ww.j  a  va 2  s . c  o  m*/

    String applicationName = args[0];
    String streamName = args[1];
    String countsTableName = args[2];
    Region region = AppUtils.parseRegion(args[3]);

    AWSCredentialsProvider credentialsProvider = new DefaultAWSCredentialsProviderChain();

    ClientConfiguration clientConfig = AppUtils.configureUserAgentForSample(new ClientConfiguration());

    AmazonKinesis kinesis = new AmazonKinesisClient(credentialsProvider, clientConfig);
    kinesis.setRegion(region);

    AmazonDynamoDB dynamoDB = new AmazonDynamoDBClient(credentialsProvider, clientConfig);
    dynamoDB.setRegion(region);

    StreamUtils streamUtils = new StreamUtils(kinesis);
    DynamoDBUtils dynamoDBUtils = new DynamoDBUtils(dynamoDB);

    LOG.info("Removing Amazon Kinesis and DynamoDB resources used by the sample application...");

    streamUtils.deleteStream(streamName);

    // The Kinesis Client Library creates a table to manage shard leases and uses the application name for its name.
    dynamoDBUtils.deleteTable(applicationName);
    dynamoDBUtils.deleteTable(countsTableName);
}

From source file:examples.nntp.newsgroups.java

public final static void main(String[] args) {
    NNTPClient client;//from www .ja va2  s  .c  o  m
    NewsgroupInfo[] list;

    if (args.length < 1) {
        System.err.println("Usage: newsgroups newsserver");
        System.exit(1);
    }

    client = new NNTPClient();

    try {
        client.connect(args[0]);

        list = client.listNewsgroups();

        if (list != null) {
            for (int i = 0; i < list.length; i++)
                System.out.println(list[i].getNewsgroup());
        } else {
            System.err.println("LIST command failed.");
            System.err.println("Server reply: " + client.getReplyString());
        }
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        try {
            if (client.isConnected())
                client.disconnect();
        } catch (IOException e) {
            System.err.println("Error disconnecting from server.");
            e.printStackTrace();
            System.exit(1);
        }
    }

}

From source file:com.lightboxtechnologies.spectrum.InfoPutter.java

public static void main(String[] args) throws IOException {
    final Configuration conf = HBaseConfiguration.create();

    final String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs();

    if (otherArgs.length != 2) {
        System.err.println("Usage: InfoPutter <imageID> <friendly_name>");
        System.exit(1);
    }/*from ww  w . j a v  a  2 s  .  c o m*/

    final String imageID = otherArgs[0];
    final String friendlyName = otherArgs[1];

    HTable imgTable = null;

    try {
        imgTable = HBaseTables.summon(conf, HBaseTables.IMAGES_TBL_B, HBaseTables.IMAGES_COLFAM_B);

        // check whether the image ID is in the images table
        final byte[] hash = Bytes.toBytes(imageID);

        final Get get = new Get(hash);
        final Result result = imgTable.get(get);

        if (result.isEmpty()) {
            // row does not exist, add it

            final byte[] friendly_col = "friendly_name".getBytes();
            final byte[] json_col = "json".getBytes();

            final byte[] friendly_b = friendlyName.getBytes();
            final byte[] json_b = IOUtils.toByteArray(System.in);

            final Put put = new Put(hash);
            put.add(HBaseTables.IMAGES_COLFAM_B, friendly_col, friendly_b);
            put.add(HBaseTables.IMAGES_COLFAM_B, json_col, json_b);

            imgTable.put(put);

            System.exit(0);
        } else {
            // row exists, fail!
            System.exit(1);
        }
    } finally {
        imgTable.close();
    }
}

From source file:com.fuerve.villageelder.client.commandline.Main.java

/**
 * The entry point into the Village Elder command line utility.
 * @param args Command line arguments./*from w ww  .  ja v  a2s  .  c  om*/
 */
public static void main(String[] args) {
    setupCommandMap();
    System.exit(run(args));
}

From source file:com.oneops.boo.Main.java

/**
 * The main method./*from   www  .ja  v  a 2  s .  co  m*/
 *
 * @param args the arguments
 */
public static void main(String[] args) {
    BooCli cli = new BooCli();
    int exit = 0;
    try {
        exit = cli.parse(args);
    } catch (ParseException e) {
        System.err.println(e.getMessage());
        exit = Constants.EXIT_PARSE_ERROR;
    } catch (BooException e) {
        System.err.println(e.getMessage());
        exit = Constants.EXIT_BOO;
    } catch (OneOpsClientAPIException e) {
        System.err.println(e.getMessage());
        exit = Constants.EXIT_CLIENT;
    } catch (Exception e) {
        System.err.println(e.getMessage());
        exit = Constants.EXIT_UNKOWN;
    } finally {
        System.exit(exit);
    }

}

From source file:com.predic8.membrane.core.RouterCLI.java

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

    MembraneCommandLine cl = new MembraneCommandLine();
    cl.parse(args);//ww w  . ja va  2  s  .c  o m
    if (cl.needHelp()) {
        cl.printUsage();
        return;
    }

    try {
        Router.init(getConfigFile(cl), RouterCLI.class.getClassLoader()).getConfigurationManager()
                .loadConfiguration(getRulesFile(cl));
        //System.out.println("preloading cache...");
        //ApplicationCachePreLoader.init();
    } catch (ClassNotFoundException e) {

        e.printStackTrace();

    } catch (PortOccupiedException e) {
        System.err.println(e.getMessage());
        System.exit(1);
    } catch (Exception ex) {
        ex.printStackTrace();
        System.err.println(
                "Could not read rules configuration. Please specify a file containing rules using the -c command line option. Or make sure that the file "
                        + System.getenv("MEMBRANE_HOME") + "/conf/rules.xml exists");
        System.exit(1);
    }

    new RouterCLI().waitForever();

}

From source file:CountRows_Oracle.java

public static void main(String[] args) {
    Connection conn = null;// w  w w.  ja  v a2 s .  c  o m
    try {
        conn = getConnection();
        String tableName = "myTable";
        System.out.println("tableName=" + tableName);
        System.out.println("conn=" + conn);
        System.out.println("rowCount=" + countRows(conn, tableName));
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    } finally {
        // release database resources
        try {
            conn.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}