Example usage for java.lang Integer valueOf

List of usage examples for java.lang Integer valueOf

Introduction

In this page you can find the example usage for java.lang Integer valueOf.

Prototype

@HotSpotIntrinsicCandidate
public static Integer valueOf(int i) 

Source Link

Document

Returns an Integer instance representing the specified int value.

Usage

From source file:net.sf.mcf2pdf.Main.java

@SuppressWarnings("static-access")
public static void main(String[] args) {
    Options options = new Options();

    Option o = OptionBuilder.hasArg().isRequired()
            .withDescription("Installation location of My CEWE Photobook. REQUIRED.").create('i');
    options.addOption(o);//from w  w  w  .  j ava  2s.  c  o m
    options.addOption("h", false, "Prints this help and exits.");
    options.addOption("t", true, "Location of MCF temporary files.");
    options.addOption("w", true, "Location for temporary images generated during conversion.");
    options.addOption("r", true, "Sets the resolution to use for page rendering, in DPI. Default is 150.");
    options.addOption("n", true, "Sets the page number to render up to. Default renders all pages.");
    options.addOption("b", false, "Prevents rendering of binding between double pages.");
    options.addOption("x", false, "Generates only XSL-FO content instead of PDF content.");
    options.addOption("q", false, "Quiet mode - only errors are logged.");
    options.addOption("d", false, "Enables debugging logging output.");

    CommandLine cl;
    try {
        CommandLineParser parser = new PosixParser();
        cl = parser.parse(options, args);
    } catch (ParseException pe) {
        printUsage(options, pe);
        System.exit(3);
        return;
    }

    if (cl.hasOption("h")) {
        printUsage(options, null);
        return;
    }

    if (cl.getArgs().length != 2) {
        printUsage(options,
                new ParseException("INFILE and OUTFILE must be specified. Arguments were: " + cl.getArgList()));
        System.exit(3);
        return;
    }

    File installDir = new File(cl.getOptionValue("i"));
    if (!installDir.isDirectory()) {
        printUsage(options, new ParseException("Specified installation directory does not exist."));
        System.exit(3);
        return;
    }

    File tempDir = null;
    String sTempDir = cl.getOptionValue("t");
    if (sTempDir == null) {
        tempDir = new File(new File(System.getProperty("user.home")), ".mcf");
        if (!tempDir.isDirectory()) {
            printUsage(options, new ParseException("MCF temporary location not specified and default location "
                    + tempDir + " does not exist."));
            System.exit(3);
            return;
        }
    } else {
        tempDir = new File(sTempDir);
        if (!tempDir.isDirectory()) {
            printUsage(options, new ParseException("Specified temporary location does not exist."));
            System.exit(3);
            return;
        }
    }

    File mcfFile = new File(cl.getArgs()[0]);
    if (!mcfFile.isFile()) {
        printUsage(options, new ParseException("MCF input file does not exist."));
        System.exit(3);
        return;
    }
    mcfFile = mcfFile.getAbsoluteFile();

    File tempImages = new File(new File(System.getProperty("user.home")), ".mcf2pdf");
    if (cl.hasOption("w")) {
        tempImages = new File(cl.getOptionValue("w"));
        if (!tempImages.mkdirs() && !tempImages.isDirectory()) {
            printUsage(options,
                    new ParseException("Specified working dir does not exist and could not be created."));
            System.exit(3);
            return;
        }
    }

    int dpi = 150;
    if (cl.hasOption("r")) {
        try {
            dpi = Integer.valueOf(cl.getOptionValue("r")).intValue();
            if (dpi < 30 || dpi > 600)
                throw new IllegalArgumentException();
        } catch (Exception e) {
            printUsage(options,
                    new ParseException("Parameter for option -r must be an integer between 30 and 600."));
        }
    }

    int maxPageNo = -1;
    if (cl.hasOption("n")) {
        try {
            maxPageNo = Integer.valueOf(cl.getOptionValue("n")).intValue();
            if (maxPageNo < 0)
                throw new IllegalArgumentException();
        } catch (Exception e) {
            printUsage(options, new ParseException("Parameter for option -n must be an integer >= 0."));
        }
    }

    boolean binding = true;
    if (cl.hasOption("b")) {
        binding = false;
    }

    OutputStream finalOut;
    if (cl.getArgs()[1].equals("-"))
        finalOut = System.out;
    else {
        try {
            finalOut = new FileOutputStream(cl.getArgs()[1]);
        } catch (IOException e) {
            printUsage(options, new ParseException("Output file could not be created."));
            System.exit(3);
            return;
        }
    }

    // configure logging, if no system property is present
    if (System.getProperty("log4j.configuration") == null) {
        PropertyConfigurator.configure(Main.class.getClassLoader().getResource("log4j.properties"));

        Logger.getRootLogger().setLevel(Level.INFO);
        if (cl.hasOption("q"))
            Logger.getRootLogger().setLevel(Level.ERROR);
        if (cl.hasOption("d"))
            Logger.getRootLogger().setLevel(Level.DEBUG);
    }

    // start conversion to XSL-FO
    // if -x is specified, this is the only thing we do
    OutputStream xslFoOut;
    if (cl.hasOption("x"))
        xslFoOut = finalOut;
    else
        xslFoOut = new ByteArrayOutputStream();

    Log log = LogFactory.getLog(Main.class);

    try {
        new Mcf2FoConverter(installDir, tempDir, tempImages).convert(mcfFile, xslFoOut, dpi, binding,
                maxPageNo);
        xslFoOut.flush();

        if (!cl.hasOption("x")) {
            // convert to PDF
            log.debug("Converting XSL-FO data to PDF");
            byte[] data = ((ByteArrayOutputStream) xslFoOut).toByteArray();
            PdfUtil.convertFO2PDF(new ByteArrayInputStream(data), finalOut, dpi);
            finalOut.flush();
        }
    } catch (Exception e) {
        log.error("An exception has occured", e);
        System.exit(1);
        return;
    } finally {
        if (finalOut instanceof FileOutputStream) {
            try {
                finalOut.close();
            } catch (Exception e) {
            }
        }
    }
}

From source file:jfractus.app.Main.java

public static void main(String[] args) {
    createCommandLineOptions();//from  www. j a  v  a  2 s  .co m
    GnuParser parser = new GnuParser();
    HelpFormatter helpFormatter = new HelpFormatter();
    helpFormatter.setOptionComparator(null);

    CommandLine cmdLine = null;

    try {
        cmdLine = parser.parse(cliOptions, args);
    } catch (ParseException e) {
        System.err.println(Resources.getString("CLIParseError"));
        return;
    }

    String functionsLibPaths = cmdLine.getOptionValue("libraries");
    int threadsNum = FractusPreferencesFactory.prefs.getThreadsNumber();
    Dimension outSize = new Dimension(FractusPreferencesFactory.prefs.getDefaultImageWidth(),
            FractusPreferencesFactory.prefs.getDefaultImageHeight());
    AntialiasConfig aaConfig = FractusPreferencesFactory.prefs.getDefaultAntialiasConfig();
    boolean printProgress = cmdLine.hasOption("progress");

    try {
        String threadsNumString = cmdLine.getOptionValue("threads");
        String imageSizeString = cmdLine.getOptionValue("image-size");
        String aaMethodString = cmdLine.getOptionValue("antialias");
        String samplingSizeString = cmdLine.getOptionValue("sampling-size");

        if (functionsLibPaths != null)
            FunctionsLoaderFactory.loader.setClassPathsFromString(functionsLibPaths);

        if (aaMethodString != null) {
            if (aaMethodString.equals("none"))
                aaConfig.setMethod(AntialiasConfig.Method.NONE);
            else if (aaMethodString.equals("normal"))
                aaConfig.setMethod(AntialiasConfig.Method.NORMAL);
            else
                throw new BadValueOfArgumentException("Bad value of argument");
        }
        if (threadsNumString != null)
            threadsNum = Integer.valueOf(threadsNumString).intValue();
        if (imageSizeString != null)
            parseSize(imageSizeString, outSize);
        if (samplingSizeString != null) {
            Dimension samplingSize = new Dimension();
            parseSize(samplingSizeString, samplingSize);
            aaConfig.setSamplingSize(samplingSize.width, samplingSize.height);
        }

        if (cmdLine.hasOption("save-prefs")) {
            FunctionsLoaderFactory.loader.putClassPathsToPrefs();
            FractusPreferencesFactory.prefs.setThreadsNumber(threadsNum);
            FractusPreferencesFactory.prefs.setDefaultImageSize(outSize.width, outSize.height);
            FractusPreferencesFactory.prefs.setDefaultAntialiasConfig(aaConfig);
        }
    } catch (ArgumentParseException e) {
        System.err.println(Resources.getString("CLIParseError"));
        return;
    } catch (NumberFormatException e) {
        System.err.println(Resources.getString("CLIParseError"));
        return;
    } catch (BadValueOfArgumentException e) {
        System.err.println(Resources.getString("CLIBadValueError"));
        return;
    }

    if (cmdLine.hasOption('h') || (cmdLine.hasOption('n') && cmdLine.getArgs().length < 2)) {
        helpFormatter.printHelp(Resources.getString("CLISyntax"), cliOptions);
        return;
    }

    if (!cmdLine.hasOption('n')) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
            }
        });
    } else {
        String[] cmdArgs = cmdLine.getArgs();
        try {
            FractalDocument fractal = new FractalDocument();
            fractal.readFromFile(new File(cmdArgs[0]));
            FractalRenderer renderer = new FractalRenderer(outSize.width, outSize.height, aaConfig, fractal);
            FractalImageWriter imageWriter = new FractalImageWriter(renderer, cmdArgs[1]);

            renderer.setThreadNumber(threadsNum);
            renderer.prepareFractal();
            if (printProgress) {
                renderer.addRenderProgressListener(new CMDLineProgressEventListener());
                imageWriter.addImageWriterProgressListener(new CMDLineImageWriteProgressListener());
            }

            imageWriter.write();
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
    }
}

From source file:com.momab.dstool.DSTool.java

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

    final CommandLineParser parser = new BasicParser();
    final Options options = commandLineOptions();
    final CommandLine line = parser.parse(options, args);

    if (args.length == 0) {
        printUsage(options, System.out);
        System.exit(0);// ww  w  . j  a va2  s.  com
    }

    if (args.length == 1 && line.hasOption("h")) {
        printHelp(options, System.out);
        System.exit(0);
    }

    if (!line.hasOption("r") && !line.hasOption("w") && !line.hasOption("d")) {
        printErrorMessage("One of the options -r -w or -d must be specified.", System.err);
        System.exit(-1);
    }

    if (line.getArgs().length != 2) {
        printErrorMessage("To few arguments.", System.err);
        System.exit(-1);
    }

    DSOperation op = null;

    // Required operands/arguments
    DSOperationBuilder opBuilder = new DSOperationBuilder(line.getArgs()[0], line.getArgs()[1]);

    // Username and password
    if (line.hasOption("u") || line.hasOption("p")) {
        if (!line.hasOption("u") || !line.hasOption("p")) {
            printErrorMessage("Missing username or password", System.err);
            System.exit(-1);
        }

        opBuilder.asUser(line.getOptionValue("u"), line.getOptionValue("p"));
    }

    // Port
    if (line.hasOption("P")) {
        opBuilder = opBuilder.usingPort(Integer.valueOf(line.getOptionValue("P")));
    }

    // File
    File file = null;
    OutputStream out = null;
    InputStream in = null;
    if (line.hasOption("f")) {
        if (line.hasOption("d")) {
            printErrorMessage("Option -f is invalid for a -d delete operation", System.err);
            System.exit(-1);
        }

        file = new File(line.getOptionValue("f"));
    }

    // Read (download) operation
    if (line.hasOption("r")) {

        if (file != null) {
            out = new FileOutputStream(file);
        } else {
            out = System.out;
        }

        opBuilder = opBuilder.writeTo(out);

        op = opBuilder.buildDownload();
    }

    // Write (upload) operation
    if (line.hasOption("w")) {

        if (file != null) {
            in = new FileInputStream(file);
        } else {
            in = System.in;
        }

        opBuilder = opBuilder.readFrom(in);

        op = opBuilder.buildUpload();
    }

    // Delete (upload) operation
    if (line.hasOption("d")) {
        op = opBuilder.buildDelete();
    }

    if (file != null || line.hasOption("d")) {
        boolean result = op.Run(new ProgressPrinter() {
        });

        if (in != null)
            in.close();
        if (out != null)
            out.close();

        System.exit(result ? 0 : -1);

    } else {
        System.exit(op.Run(null) ? 0 : -1);
    }

}

From source file:com.flaptor.indextank.storage.IndexesLogServer.java

public static void main(String[] args) throws IOException, InterruptedException {
    // create the parser
    CommandLineParser parser = new PosixParser();

    int readerPort, managerPort;

    try {//  ww w .  ja  v  a 2  s  .c om
        // parse the command line arguments
        CommandLine line = parser.parse(getOptions(), args);
        if (line.hasOption("help")) {
            printHelp(getOptions(), null);
            System.exit(1);
            return;
        }

        String val = null;
        val = line.getOptionValue("reader_port", null);
        if (null != val) {
            readerPort = Integer.valueOf(val);
        } else {
            printHelp(getOptions(), "Must specify a server port");
            System.exit(1);
            return;
        }
        val = null;
        val = line.getOptionValue("manager_port", null);
        if (null != val) {
            managerPort = Integer.valueOf(val);
        } else {
            printHelp(getOptions(), "Must specify a server port");
            System.exit(1);
            return;
        }
    } catch (ParseException exp) {
        printHelp(getOptions(), exp.getMessage());
        System.exit(1);
        return;
    }

    new IndexesLogServer(readerPort, managerPort).start();
}

From source file:com.zimbra.common.util.RandomPassword.java

public static void main(String args[]) {
    CommandLineParser parser = new GnuParser();
    Options options = new Options();
    options.addOption("l", "localpart", false, "generated string does not contain dot(.)");

    CommandLine cl = null;//from w  w w  .  ja va 2  s .  co m
    boolean err = false;

    try {
        cl = parser.parse(options, args, true);
    } catch (ParseException pe) {
        System.err.println("error: " + pe.getMessage());
        err = true;
    }

    if (err || cl.hasOption('h')) {
        usage();
    }

    boolean localpart = false;
    int minLength = DEFAULT_MIN_LENGTH;
    int maxLength = DEFAULT_MAX_LENGTH;

    if (cl.hasOption('l'))
        localpart = true;

    args = cl.getArgs();

    if (args.length != 0) {
        if (args.length != 2) {
            usage();
        }
        try {
            minLength = Integer.valueOf(args[0]).intValue();
            maxLength = Integer.valueOf(args[1]).intValue();
        } catch (Exception e) {
            System.err.println(e);
            e.printStackTrace();
        }
    }

    System.out.println(generate(minLength, maxLength, localpart));
}

From source file:com.flaptor.indextank.storage.LogWriterServer.java

public static void main(String[] args) throws IOException, InterruptedException {
    // create the parser
    CommandLineParser parser = new PosixParser();

    int port;//  www .ja  v a  2s. c  om

    LogWriterServer server;
    try {
        // parse the command line arguments
        CommandLine line = parser.parse(getOptions(), args);
        if (line.hasOption("help")) {
            printHelp(getOptions(), null);
            System.exit(1);
            return;
        }

        String val = null;
        val = line.getOptionValue("port", null);
        if (null != val) {
            port = Integer.valueOf(val);
        } else {
            printHelp(getOptions(), "Must specify a server port");
            System.exit(1);
            return;
        }

        String path = null;
        path = line.getOptionValue("path", null);
        if (null != path) {
            server = new LogWriterServer(new File(path), port);
        } else {
            server = new LogWriterServer(port);
        }
    } catch (ParseException exp) {
        printHelp(getOptions(), exp.getMessage());
        System.exit(1);
        return;
    }

    server.start();
}

From source file:com.github.brandtg.switchboard.MysqlReplicator.java

/** Main. */
public static void main(String[] args) throws Exception {
    Options options = new Options();
    options.addOption("u", "user", true, "MySQL user");
    options.addOption("p", "password", true, "MySQL password");
    options.addOption("h", "host", true, "MySQL host");
    options.addOption("P", "port", true, "MySQL port");
    options.addOption("s", "sinkPort", true, "Local sink port");
    options.addOption("l", "lastIndex", true, "Last transaction ID");
    options.addOption("h", "help", false, "Prints help message");
    CommandLine commandLine = new GnuParser().parse(options, args);

    if (commandLine.getArgs().length < 2 || commandLine.hasOption("help")) {
        HelpFormatter helpFormatter = new HelpFormatter();
        helpFormatter.printHelp("usage: [opts] switchboardHost:port db1 [db2 ...]", options);
        System.exit(1);/*from  w  w w. j a va2  s .c om*/
    }

    // Switchboard host
    String[] hostPort = commandLine.getArgs()[0].split(":");
    InetSocketAddress source = new InetSocketAddress(hostPort[0], Integer.valueOf(hostPort[1]));
    InetSocketAddress sink = new InetSocketAddress(
            Integer.valueOf(commandLine.getOptionValue("sinkPort", "9090")));

    // Databases to replicate
    String[] databases = Arrays.copyOfRange(commandLine.getArgs(), 1, commandLine.getArgs().length);

    // JDBC params for local copy
    String user = commandLine.getOptionValue("user", "root");
    String password = commandLine.getOptionValue("password", "");
    String jdbcString = String.format("jdbc:mysql://%s:%d", commandLine.getOptionValue("host", "localhost"),
            Integer.valueOf(commandLine.getOptionValue("port", "3306")));
    Long lastIndex = Long.valueOf(commandLine.getOptionValue("lastIndex", "-1"));

    // Create replicators
    final List<MysqlReplicator> replicators = new ArrayList<>();
    for (String database : databases) {
        MysqlReplicator replicator = new MysqlReplicator(database, source, sink, jdbcString, user, password,
                lastIndex);
        replicators.add(replicator);
    }

    // Shutdown hook
    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            for (MysqlReplicator replicator : replicators) {
                try {
                    replicator.shutdown();
                } catch (Exception e) {
                    LOG.error("Could not shut down {}", replicator, e);
                }
            }
        }
    });

    for (MysqlReplicator replicator : replicators) {
        replicator.start();
        LOG.info("Started {}", replicator);
    }
}

From source file:Text2ColumntStorageMR.java

@SuppressWarnings("deprecation")
public static void main(String[] args) throws Exception {

    if (args.length != 3) {
        System.out.println("Text2ColumnStorageMR <input> <output> <columnStorageMode>");
        System.exit(-1);//from   ww w.  j ava 2 s .c o  m
    }

    JobConf conf = new JobConf(Text2ColumntStorageMR.class);

    conf.setJobName("Text2ColumnStorageMR");

    conf.setNumMapTasks(1);
    conf.setNumReduceTasks(4);

    conf.setOutputKeyClass(LongWritable.class);
    conf.setOutputValueClass(Unit.Record.class);

    conf.setMapperClass(TextFileMapper.class);
    conf.setReducerClass(ColumnStorageReducer.class);

    conf.setInputFormat(TextInputFormat.class);
    conf.setOutputFormat((Class<? extends OutputFormat>) ColumnStorageHiveOutputFormat.class);
    conf.set("mapred.output.compress", "flase");

    Head head = new Head();
    initHead(head);

    head.toJobConf(conf);

    int bt = Integer.valueOf(args[2]);

    FileInputFormat.setInputPaths(conf, args[0]);
    Path outputPath = new Path(args[1]);
    FileOutputFormat.setOutputPath(conf, outputPath);

    FileSystem fs = outputPath.getFileSystem(conf);
    fs.delete(outputPath, true);

    JobClient jc = new JobClient(conf);
    RunningJob rj = null;
    rj = jc.submitJob(conf);

    String lastReport = "";
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss,SSS");
    long reportTime = System.currentTimeMillis();
    long maxReportInterval = 3 * 1000;
    while (!rj.isComplete()) {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
        }

        int mapProgress = Math.round(rj.mapProgress() * 100);
        int reduceProgress = Math.round(rj.reduceProgress() * 100);

        String report = " map = " + mapProgress + "%,  reduce = " + reduceProgress + "%";

        if (!report.equals(lastReport) || System.currentTimeMillis() >= reportTime + maxReportInterval) {

            String output = dateFormat.format(Calendar.getInstance().getTime()) + report;
            System.out.println(output);
            lastReport = report;
            reportTime = System.currentTimeMillis();
        }
    }

    System.exit(0);

}

From source file:com.redhat.smonkey.Monkey.java

public static void main(String[] args) throws Exception {
    GeneratorRegistry registry = GeneratorRegistry.getDefaultInstance();
    if (args.length > 0) {
        Monkey m = Monkey.getInstance(registry, args[0]);
        int n = 1;
        if (args.length == 2)
            n = Integer.valueOf(args[1]);
        JsonNode node;/*from  ww w  .j av  a2s.  c om*/
        if (n > 1) {
            node = nodeFactory.arrayNode();
            for (int i = 0; i < n; i++)
                ((ArrayNode) node).add(m.generate());
        } else
            node = m.generate();
        System.out.println(Utils.prettyPrint(node));
    } else
        printHelp(registry);
}

From source file:ch.epfl.leb.sass.commandline.CommandLineInterface.java

/**
 * Shows help, launches the interpreter and executes scripts according to input args.
 * @param args input arguments//from   w  ww.  j  a  va2s .c  o  m
 */
public static void main(String args[]) {
    // parse input arguments
    CommandLineParser parser = new DefaultParser();
    CommandLine line = null;
    try {
        line = parser.parse(options, args);
    } catch (ParseException ex) {
        System.err.println("Parsing of arguments failed. Reason: " + ex.getMessage());
        System.err.println("Use -help for usage.");
        System.exit(1);
    }

    // decide how do we make the interpreter available based on options
    Interpreter interpreter = null;
    // show help and exit
    if (line.hasOption("help")) {
        HelpFormatter helpFormatter = new HelpFormatter();
        helpFormatter.printHelp("java -jar <jar-name>", options, true);
        System.exit(0);
        // launch interpreter inside current terminal
    } else if (line.hasOption("interpreter")) {
        // assign in, out and err streams to the interpreter
        interpreter = new Interpreter(new InputStreamReader(System.in), System.out, System.err, true);
        interpreter.setShowResults(true);
        // if a script was given, execute it before giving access to user
        if (line.hasOption("script")) {
            try {
                interpreter.source(line.getOptionValue("script"));
            } catch (IOException ex) {
                Logger.getLogger(BeanShellConsole.class.getName()).log(Level.SEVERE,
                        "IOException while executing shell script.", ex);
            } catch (EvalError ex) {
                Logger.getLogger(BeanShellConsole.class.getName()).log(Level.SEVERE,
                        "EvalError while executing shell script.", ex);
            }
        }
        // give access to user
        new Thread(interpreter).start();
        // only execute script and exit
    } else if (line.hasOption("script")) {
        interpreter = new Interpreter();
        try {
            interpreter.source(line.getOptionValue("script"));
            System.exit(0);
        } catch (IOException ex) {
            Logger.getLogger(BeanShellConsole.class.getName()).log(Level.SEVERE,
                    "IOException while executing shell script.", ex);
            System.exit(1);
        } catch (EvalError ex) {
            Logger.getLogger(BeanShellConsole.class.getName()).log(Level.SEVERE,
                    "EvalError while executing shell script.", ex);
            System.exit(1);
        }

        // Launches the RPC server with the model contained in the file whose
        // filename was passed by argument.
    } else if (line.hasOption("rpc_server")) {

        IJPluginModel model = new IJPluginModel();
        File file = new File(line.getOptionValue("rpc_server"));
        try {
            FileInputStream stream = new FileInputStream(file);
            model = IJPluginModel.read(stream);
        } catch (FileNotFoundException ex) {
            System.out.println("Error: " + file.getName() + " not found.");
            System.exit(1);
        } catch (Exception ex) {
            ex.printStackTrace();
        }

        // Check whether a port number was specified.
        if (line.hasOption("port")) {
            try {
                port = Integer.valueOf(line.getOptionValue("port"));
                System.out.println("Using port: " + String.valueOf(port));
            } catch (java.lang.NumberFormatException ex) {
                System.out.println("Error: the port number argument is not a number.");
                System.exit(1);
            }
        } else {
            System.out.println("No port number provided. Using default port: " + String.valueOf(port));
        }

        RPCServer server = new RPCServer(model, port);

        System.out.println("Starting RPC server...");
        server.serve();

    } else if (line.hasOption("port") & !line.hasOption("rpc_server")) {
        System.out.println("Error: Port number provided without requesting the RPC server. Exiting...");
        System.exit(1);

        // if System.console() returns null, it means we were launched by
        // double-clicking the .jar, so launch own BeanShellConsole
        // if System.console() returns null, it means we were launched by
        // double-clicking the .jar, so launch own ConsoleFrame
    } else if (System.console() == null) {
        BeanShellConsole cframe = new BeanShellConsole("SASS BeanShell Prompt");
        interpreter = cframe.getInterpreter();
        cframe.setVisible(true);
        System.setOut(cframe.getInterpreter().getOut());
        System.setErr(cframe.getInterpreter().getErr());
        new Thread(cframe.getInterpreter()).start();
        // otherwise, show help
    } else {
        HelpFormatter helpFormatter = new HelpFormatter();
        helpFormatter.printHelp("java -jar <jar-name>", options, true);
        System.exit(0);
    }

    if (interpreter != null) {
        printWelcomeText(interpreter.getOut());
    }
}