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:net.hedges.fandangled.commandline.GenericCli.java

public static void main(String[] args) {
    options = buildOptions();/*from   w  w w . j a  v a 2  s . co  m*/

    try {
        CommandLineParser parser = new GnuParser();
        CommandLine line = parser.parse(options, args);
        verbose = line.hasOption('v');
        if (line.hasOption('h')) {
            usage();
            System.exit(0);
        }
        String template = line.getOptionValue("templates");
        String input = line.getOptionValue("input");
        String output = line.getOptionValue("output");

        String prefix = line.getOptionValue("prefix", "");
        String extension = line.getOptionValue("extension", ".txt");

        File inputFile = new File(input);
        File outputDir = new File(output);
        File templateDir = new File(template);

        checkFilesAndDirectories(inputFile, outputDir, templateDir);

        GenericCodec codec = new GenericCodec();
        codec.setTemplatePath(templateDir.getAbsolutePath());
        codec.setExtension(extension);
        codec.setPrefix(prefix);

        Interface _interface = InterfaceBuilder.parse(inputFile);

        codec.encode(_interface, outputDir);

    } catch (ParseException e) {
        System.err.print(e.getMessage() + "\n");
        usage();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.difference.historybook.importer.indexer.Indexer.java

public static void main(String[] args) throws IOException {
    if (args.length < 1) {
        System.err.println("usage: Indexer <inputfile>");
        System.exit(1);
    }/*from  w  ww.  jav a2 s. co  m*/

    String fileName = args[0];
    Indexer app = new Indexer(DEFAULT_BASE_URL, DEFAULT_COLLECTION);
    app.process(fileName);
}

From source file:fit.FitServer.java

public static void main(String argv[]) throws IOException {
    Guice.createInjector(new AbstractModule() {
        @Override//from  ww  w  . j  av  a  2  s.  c o  m
        protected void configure() {
            install(new UtilModule());
        }
    });
    Counts counts = runFitServer(argv);
    System.exit(exitCode(counts));
}

From source file:com.orchestrationexample.registerinfoservice.client.Client.java

public static void main(String args[]) throws Exception {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("client-context.xml");
    RegisterInfoService register = (RegisterInfoService) context.getBean("registerInfoService");

    System.out.println("Test (user exists) Aaa sss: result = " + register.checkPerson("ass", "sss"));
    System.out.println(/*from   www .  j a v  a 2s . c  o  m*/
            "Test (user exists) Jozko Mrkvicka: result = " + register.checkPerson("Jozko", "Mrkvicka"));

    System.exit(0);
}

From source file:de.andrena.tools.macker.plugin.CommandLineFile.java

public static void main(String[] args) throws Exception {
    if (args.length == 0 || args.length > 2) {
        System.err.println("Usage: CommandLineFile <main class> [command line arguments file]");
        System.exit(1);
    }//from  www. j  a va  2 s .c  om

    String className = args[0];
    Class<?> clazz = Class.forName(className);
    Method main = clazz.getMethod("main", new Class[] { String[].class });

    List<String> lines = new ArrayList<String>();
    if (args.length == 2) {
        Reader in = new InputStreamReader(new FileInputStream(args[1]), "UTF-8");
        try {
            lines = IOUtils.readLines(in);
        } finally {
            in.close();
        }
    }

    try {
        main.invoke(null, new Object[] { lines.toArray(new String[lines.size()]) });
    } catch (InvocationTargetException ex) {
        Throwable cause = ex.getTargetException();
        if (cause instanceof Error) {
            throw (Error) cause;
        }
        throw (Exception) cause;
    }
}

From source file:com.textocat.textokit.postagger.opennlp.PackageModelZipAsArtifact.java

public static void main(String[] args) throws IOException {
    PackageModelZipAsArtifact cli = new PackageModelZipAsArtifact();
    new JCommander(cli, args);
    Path inputZipPath = Paths.get(cli.inputZipPathStr);
    if (!Files.isRegularFile(inputZipPath)) {
        System.err.println(inputZipPath + " is not an existing file.");
        System.exit(1);
    }//w  w  w . j av a  2  s .  c o  m
    POSModelJarManifestBean manifestBean = new POSModelJarManifestBean(cli.languageCode, cli.modelVariant);
    Path outputJarPath = inputZipPath
            .resolveSibling(FilenameUtils.getBaseName(inputZipPath.getFileName().toString()) + ".jar");
    try (OutputStream out = new BufferedOutputStream(Files.newOutputStream(outputJarPath))) {
        JarOutputStream jout = new JarOutputStream(out, manifestBean.toManifest());
        jout.putNextEntry(new ZipEntry(ClasspathPOSModelHolder.getClassPath(manifestBean.getLanguageCode(),
                manifestBean.getModelVariant())));
        FileUtils.copyFile(inputZipPath.toFile(), jout);
        jout.closeEntry();
        jout.close();
    }
}

From source file:SystemTrayDemo2.java

public static void main(String[] args) {
    if (!SystemTray.isSupported()) {
        return;//from w w w.  jav a2s. c  o  m
    }
    SystemTray tray = SystemTray.getSystemTray();

    Dimension size = tray.getTrayIconSize();
    BufferedImage bi = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
    Graphics g = bi.getGraphics();

    g.setColor(Color.blue);
    g.fillRect(0, 0, size.width, size.height);
    g.setColor(Color.yellow);
    int ovalSize = (size.width < size.height) ? size.width : size.height;
    ovalSize /= 2;
    g.fillOval(size.width / 4, size.height / 4, ovalSize, ovalSize);

    try {
        PopupMenu popup = new PopupMenu();
        MenuItem miExit = new MenuItem("Exit");
        ActionListener al;
        al = new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                System.out.println("Goodbye");
                System.exit(0);
            }
        };
        miExit.addActionListener(al);
        popup.add(miExit);

        TrayIcon ti = new TrayIcon(bi, "System Tray Demo #2", popup);

        al = new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                System.out.println(e.getActionCommand());
            }
        };
        ti.setActionCommand("My Icon");
        ti.addActionListener(al);

        MouseListener ml;
        ml = new MouseListener() {
            public void mouseClicked(MouseEvent e) {
                System.out.println("Tray icon: Mouse clicked");
            }

            public void mouseEntered(MouseEvent e) {
                System.out.println("Tray icon: Mouse entered");
            }

            public void mouseExited(MouseEvent e) {
                System.out.println("Tray icon: Mouse exited");
            }

            public void mousePressed(MouseEvent e) {
                System.out.println("Tray icon: Mouse pressed");
            }

            public void mouseReleased(MouseEvent e) {
                System.out.println("Tray icon: Mouse released");
            }
        };
        ti.addMouseListener(ml);

        MouseMotionListener mml;
        mml = new MouseMotionListener() {
            public void mouseDragged(MouseEvent e) {
                System.out.println("Tray icon: Mouse dragged");
            }

            public void mouseMoved(MouseEvent e) {
                System.out.println("Tray icon: Mouse moved");
            }
        };
        ti.addMouseMotionListener(mml);

        tray.add(ti);
    } catch (AWTException e) {
        System.out.println(e.getMessage());
        return;
    }
}

From source file:InsertCustomType2_Oracle.java

public static void main(String[] args) {
    String id = "001";
    String isbn = "1234567890";
    String title = "Java Oracle";
    String author = "java2s";
    int edition = 1;

    // create the Book object
    Book book = new Book(isbn, title, author, edition);
    book.print();// w  w  w . jav  a 2s  . c om

    Connection conn = null;
    PreparedStatement pstmt = null;
    try {
        conn = getConnection();
        // create type map
        java.util.Map map = conn.getTypeMap();
        System.out.println("map=" + map);
        map.put("BOOK", Class.forName("Book"));
        System.out.println("map=" + map);

        String insert = "insert into book_table(ID, BOOK) values(?, ?)";
        pstmt = conn.prepareStatement(insert);
        pstmt.setString(1, id);
        pstmt.setObject(2, book);
        pstmt.executeUpdate();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    } finally {
        try {
            pstmt.close();
            conn.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}

From source file:com.aleggeup.util.App.java

public static void main(final String[] args) {
    final CommandLineParser parser = new PosixParser();
    final Options options = buildOptions();

    File sourceFile = null;/* w  w  w.j  a  v a  2 s.co m*/
    File targetFile = null;

    try {
        final CommandLine commandLine = parser.parse(options, args);

        if (commandLine.getOptions().length == 0 || commandLine.hasOption('h')) {
            printHelp(options);
            System.exit(0);
        }

        if (commandLine.hasOption('s')) {
            sourceFile = new File(commandLine.getOptionValue('s')).getCanonicalFile();
        }

        if (commandLine.hasOption('t')) {
            targetFile = new File(commandLine.getOptionValue('t')).getCanonicalFile();
        }

    } catch (final ParseException e) {
        printHelp(options);
        System.exit(-1);
    } catch (final IOException e) {
        e.printStackTrace();
    }

}

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

public static void main(String[] args) throws Exception {
    final Configuration conf = new Configuration();
    final String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs();

    if (otherArgs.length != 1) {
        System.err.println("Usage: Uploader <dest path>");
        System.err.println("Writes data to HDFS path from stdin");
        System.exit(2);
    }/*from ww  w  .ja  v a2s.  com*/

    MessageDigest hasher = FsEntryUtils.getHashInstance("MD5");
    DigestInputStream hashedIn = new DigestInputStream(System.in, hasher);

    FileSystem fs = FileSystem.get(conf);
    Path path = new Path(otherArgs[0]);
    FSDataOutputStream outFile = fs.create(path, true);

    IOUtils.copyLarge(hashedIn, outFile, new byte[1024 * 1024]);

    System.out.println(new String(Hex.encodeHex(hasher.digest())));
}