Entry point from the operating system command line.

<p>Calls {@link System#exit(int)} with the following status codes:
<ul>
<li>0: success</li>
<li>1: invalid arguments</li>
<li>2: help</li>
</ul>

@param args Command-line arguments
6950
public static void main(String[] args) {
    final PrintWriter out = new PrintWriter(System.out);
    final PrintWriter err = new PrintWriter(System.err);
    final int code = Launcher.main2(out, err, Arrays.asList(args));
    System.exit(code);
  }
1289108
protected ExitStatus run(String... args) throws Exception {
		if (args.length == 0) {
			throw new NoArgumentsException();
		}
		String commandName = args[0];
		String[] commandArguments = Arrays.copyOfRange(args, 1, args.length);
		Command command = findCommand(commandName);
		if (command == null) {
			throw new NoSuchCommandException(commandName);
		}
		beforeRun(command);
		try {
			return command.run(commandArguments);
		}
		finally {
			afterRun(command);
		}
	}
194598
public static void main(String[] args) {
        DirectoryIterator iter = new DirectoryIterator(args);
        while(iter.hasNext())
            System.out.println(iter.next().getAbsolutePath());
    }
946456
public static void main(String[] args) {
        try {
            new StartMain(args).go();
        } catch(Throwable t) {
            WeldSELogger.LOG.error("Application exited with an exception", t);
            System.exit(1);
        }
    }
1017917
public static void main(String[] args) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            javax.swing.SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    if (args.length != 0) {
                        //System.out.println("OK");
                        TaskManagerTabPanel panel = new TaskManagerTabPanel();
                        panel.runTaskCLI(args);
                        System.exit(0);

                    } else {
                        createAndShowGUI();
                    }
                }
            });
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
426586
public static void main(String args[])
    {
        System.setProperty("voltdb_no_logging", "true");
        int exitCode = mainWithReturnCode(args);
        System.exit(exitCode);
    }
287366
public static void main(String[] args) {
        ConsoleWrapper console = new ConsoleWrapper(System.console(), System.err);

        // Create the SpringBootUtility and register tasks
        SpringBootUtility util = new SpringBootUtility(console, System.out, System.err);
        IFileUtility fileUtil = new FileUtility();
        util.registerTask(new ThinAppTask(fileUtil, SCRIPT_NAME));

        // Kick everything off
        int rc = util.runProgram(args).getReturnCode();
        System.exit(rc);
    }
542138
public static void main(final String[] args) throws Exception {
        final AclTool tool = new AclTool(new DefaultCLIToolLogger());
        tool.setShouldExit(true);
        int exitCode = 1; //pessimistic initial value

        try {
            tool.run(args);
            exitCode = 0;
        } catch (OptionsPrompt e) {
            exitCode = 2;
            tool.error(e.getMessage());
            tool.error(e.getPrompt());
            if (tool.argVerbose) {
                e.printStackTrace();
            }
        } catch (CLIToolOptionsException e) {
            exitCode = 2;
            tool.error(e.getMessage());
            if (tool.argVerbose) {
                e.printStackTrace();
            }
        } catch (Throwable e) {
            if (e.getMessage() == null || tool.argVerbose) {
                e.printStackTrace();
            }
            tool.error("Error: " + e.getMessage());
        }
        tool.exit(exitCode);
    }
1125427
public static void main(final String args[]) {
        int exitCode = 1;
        final Setup setup = new Setup();
        try {
            setup.execute(args);
            exitCode = 0;
        } catch (Throwable exc) {
            System.err.println("ERROR: " + exc.getMessage());
        }
        System.exit(exitCode);
    }
176675
public void runArgs(String[] args) {
        CommandLineParser clParser = new DefaultParser();
        CommandLine line;
        String host;
        String port;
        CMD cmd;
        String[] cmdArgs;
        final PrintStream CONSOLE = System.out;
        try {
            // parse the command line arguments
            line = clParser.parse(options, args);

            if (line.hasOption("output")){
                String location = line.getOptionValue("output");
                File output = new File(location);
                FileOutputStream fos;
                try {
                    fos = new FileOutputStream(output);
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                    throw new ParseException(String.format("Wrong -o option. args %s\n",Arrays.asList(args)));
                }
                PrintStream out = new PrintStream(fos);
                System.setOut(out);

            }
            if (line.getOptions().length==0 || line.hasOption("help")) {
                if ((line.getOptions().length > 2) || (line.getOptions().length==2 && !line.hasOption("output"))){
                    throw new ParseException(String.format("Wrong -help option. args %s\n", Arrays.asList(args)));
                }
                printUsage(System.out);
            }
            if (line.hasOption("server")) {
                String server = line.getOptionValue("server");
                try {
                    host = server.split(":")[0];
                    port = server.split(":")[1];
                }catch (Exception e){
                    throw new ParseException(String.format("Wrong -server option. args %s\n", Arrays.asList(args)));
                }
                ServiceDirectory.getServiceDirectoryConfig().setProperty(
                        DirectoryServiceRestfulClient.SD_API_SD_SERVER_FQDN_PROPERTY,
                        host);
                ServiceDirectory.getServiceDirectoryConfig().setProperty(
                        DirectoryServiceRestfulClient.SD_API_SD_SERVER_PORT_PROPERTY,
                        port);
            }

            if (line.hasOption("exec")) {
                String commandString = line.getOptionValue("exec");
                cmdArgs = parseCommand(commandString);
                try {
                    cmd = CMD.valueOf(cmdArgs[0]);
                } catch (IllegalArgumentException e) {
                    throw new ParseException(String.format("Unknown command [ %s ] \n", commandString));
                }
                if (cmd.sizeOfArgs + 1 != cmdArgs.length) {
                    throw new ParseException(
                            String.format("Wrong arguments number for command %s, required %s but %s \n",
                                    cmdArgs[0], cmd.sizeOfArgs, cmdArgs.length - 1));
                }
                switch (cmd) {
                    case getInstanceOf:
                        lookupInstance(cmdArgs);
                        break;
                    case getAllInstancesOf:
                        lookupInstances(cmdArgs);
                        break;
                    case getAllServices:
                        getAllServices();
                        break;
                    case registerService:
                        registerService(cmdArgs);
                        break;
                    default:
                        fail("command " + cmd + " is unsupported yet");
                        break;
                }

            }
        } catch (ParseException exp) {
            // oops, something went wrong
            exp.printStackTrace();
            try {
                TimeUnit.MILLISECONDS.sleep(100L);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            printUsage(System.err);
        }
        System.setOut(CONSOLE);
    }
1195423
public static void main(String[] args) {
    if (args.length == 0) {
      Options.help(true);
    }
    long startTime = System.currentTimeMillis();

    List<String> files = null;
    Options options = new Options();

    try {
      files = options.load(args);
      if (files.isEmpty()) {
        Options.usage("no source files");
      }
    } catch (IOException e) {
      ErrorUtil.error(e.getMessage());
      System.exit(1);
    }

    run(files, options);

    TimingLevel timingLevel = options.timingLevel();
    if (timingLevel == TimingLevel.TOTAL || timingLevel == TimingLevel.ALL) {
      System.out.printf("j2objc execution time: %d ms\n", System.currentTimeMillis() - startTime);
    }

    // Run last, since it calls System.exit() with the number of errors.
    checkErrors(options.treatWarningsAsErrors());
  }
183099
public static void main(final String[] args) {
        Switch about = new Switch("a", "about", "display about message");
        Switch help = new Switch("h", "help", "display help message");
        FileArgument firstFastqFile = new FileArgument("1", "first-fastq-file", "first FASTQ input file", true);
        FileArgument secondFastqFile = new FileArgument("2", "second-fastq-file", "second FASTQ input file", true);
        FileArgument pairedFile = new FileArgument("p", "paired-file", "output interleaved paired FASTQ file", true);
        FileArgument unpairedFile = new FileArgument("u", "unpaired-file", "output unpaired FASTQ file", true);

        ArgumentList arguments = new ArgumentList(about, help, firstFastqFile, secondFastqFile, pairedFile, unpairedFile);
        CommandLine commandLine = new CommandLine(args);

        InterleaveFastq interleaveFastq = null;
        try {
            CommandLineParser.parse(commandLine, arguments);
            if (about.wasFound()) {
                About.about(System.out);
                System.exit(0);
            }
            if (help.wasFound()) {
                Usage.usage(USAGE, null, commandLine, arguments, System.out);
                System.exit(0);
            }
            interleaveFastq = new InterleaveFastq(firstFastqFile.getValue(), secondFastqFile.getValue(), pairedFile.getValue(), unpairedFile.getValue());
        }
        catch (CommandLineParseException e) {
            if (about.wasFound()) {
                About.about(System.out);
                System.exit(0);
            }
            if (help.wasFound()) {
                Usage.usage(USAGE, null, commandLine, arguments, System.out);
                System.exit(0);
            }
            Usage.usage(USAGE, e, commandLine, arguments, System.err);
            System.exit(-1);
        }
        try {
            System.exit(interleaveFastq.call());
        }
        catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }
267027
public static void main(final String[] args) {
        Switch about = new Switch("a", "about", "display about message");
        Switch help = new Switch("h", "help", "display help message");
        FileArgument fastaFile = new FileArgument("i", "fasta-file", "input FASTA file, default stdin", false);
        StringArgument outputFilePrefix = new StringArgument("p", "output-file-prefix", "output file prefix, default \"\"", false);
        StringArgument outputFileExtension = new StringArgument("x", "output-file-extension", "output file extension, default " + DEFAULT_OUTPUT_FILE_EXTENSION, false);
        FileArgument outputDirectory = new FileArgument("d", "output-directory", "output directory, default .", false);

        ArgumentList arguments = new ArgumentList(about, help, fastaFile, outputFilePrefix, outputFileExtension, outputDirectory);
        CommandLine commandLine = new CommandLine(args);

        SplitFasta splitFasta = null;
        try
        {
            CommandLineParser.parse(commandLine, arguments);
            if (about.wasFound()) {
                About.about(System.out);
                System.exit(0);
            }
            if (help.wasFound()) {
                Usage.usage(USAGE, null, commandLine, arguments, System.out);
                System.exit(0);
            }
            splitFasta = new SplitFasta(fastaFile.getValue(), outputFilePrefix.getValue(DEFAULT_OUTPUT_FILE_PREFIX), outputFileExtension.getValue(DEFAULT_OUTPUT_FILE_EXTENSION), outputDirectory.getValue(DEFAULT_OUTPUT_DIRECTORY));
        }
        catch (CommandLineParseException e) {
            Usage.usage(USAGE, e, commandLine, arguments, System.err);
            System.exit(-1);
        }
        try {
            System.exit(splitFasta.call());
        }
        catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }
1127533
public static void main(String [] args ){
        if (args.length != 3){            
            printUsage();
            System.exit(1);
        }
        
        boolean label = (args[0].toLowerCase().trim().equals("-lbl"));
        
        try{
            String inputWhat = args[1].toLowerCase().trim();
        
            if (inputWhat.equals("-inputfile"))
            {
                BufferedReader in = new BufferedReader(new InputStreamReader(
                        new FileInputStream(args[2]), "UTF-8"));
                
                BufferedWriter out = new BufferedWriter(new OutputStreamWriter(
                        new FileOutputStream(args[2] + ".tagged"), "UTF-8"));

                String text = "", line = "";                
                while ((line = in.readLine()) != null){
                    text += "\n" + line;
                }
                text = text.trim();

                //text normalization 
                text = text.replaceAll("([\t\n\r ])+", "$1");                
                text = text.replaceAll("[\\[\\]]", "");                
                text = text.replaceAll("<[^<>]*>", "");
                    
                List MarkList = new ArrayList();
                
                ArrayList recordList =  (ArrayList) doFeatureGen(
                        new HashMap(), text , MarkList, label) ;

                for (int i = 0; i < recordList.size(); ++i){
                
                    out.write(recordList.get(i).toString());
                    
                    out.write("\n");
                
                }

                in.close();
                out.close();
            }

            else if (inputWhat.equals("-inputdir")){
                
                BufferedWriter out = new BufferedWriter(new OutputStreamWriter(
                        new FileOutputStream(args[2] + ".tagged"), "UTF-8"));

                File inputDir = new File(args[2]);
                File [] childrent = inputDir.listFiles();
                
                for (int i = 0; i <childrent.length; ++i)
                {
                    //go through all the file in the input file and do feagen
                    BufferedReader in = new BufferedReader(new InputStreamReader(
                            new FileInputStream(childrent[i]), "UTF-8"));

                    String text = "", line = "";                    
                    while ((line = in.readLine()) != null){
                        text += "\n" + line;
                    }                    
                    text = text.trim();
                    
                    //text normalization 
                    text = text.replaceAll("([\t\n\r ])+", "$1");                 
                    text = text.replaceAll("[\\[\\]{}]", "");                    
                    text = text.replaceAll("<[^<>]*>", "");

                    List MarkList = new ArrayList();
                    ArrayList recordList = (ArrayList) doFeatureGen(
                            new HashMap(), text , MarkList, label) ;

                    
                    for (int j = 0; j < recordList.size(); ++j){                    
                        out.write(recordList.get(j).toString());                    
                        out.write("\n");
                    }

                    in.close();                 
                }
                out.close();
            }
         
            else printUsage();
        }
        catch (Exception e)
        {
            System.out.println("In feature generator main : " + e.getMessage());
            return;
        }
        
    }
800145
protected int runProgram(String[] args) {
        // If no args, dump usage and exit.
        if (args == null || args.length == 0) {
            stdout.println(getScriptUsage());
            return 0;
        }

        String action = args[0];
        String actionTarget = args.length >= 2 ? args[1] : "";
        if (action == null || action.isEmpty() || action.toLowerCase().equals("help")) {
            if (actionTarget.isEmpty() || "help".equalsIgnoreCase(actionTarget)) {
                stdout.println(getScriptUsage());
                stdout.println(getActions());
                return 0;
            } else if ("generate".equalsIgnoreCase(actionTarget)) {
                stderr.println(getMessage("generate.help"));
                return 0;
            } else {
                stderr.println(getMessage("action.unrecognized", actionTarget));
                stdout.println(getScriptUsage());
                return RC_INVALID_OPTION;
            }
        }

        // Make sure we were provided a valid action. If not print help and return invalid
        if ("generate".equalsIgnoreCase(action) == false) {
            stderr.println(getMessage("action.unrecognized", action));
            stdout.println(getScriptUsage());
            return RC_INVALID_OPTION;
        }

        String userDir = getUserDir();
        // The server name should be the second argument.  Go find the server.  If we can't find the server, print the help text.
        String serverName = actionTarget;
        File serverDirectory = new File(userDir + File.separator + "servers" + File.separator + serverName);
        if (serverName.isEmpty() || (serverDirectory.exists() == false) || (serverDirectory.isDirectory() == false)) {
            stderr.println(getMessage("server.not.found", serverName, serverDirectory.getAbsolutePath()));
            stdout.println(getScriptUsage());
            return RC_SERVER_NOT_FOUND;
        }

        // Check the output dir.. If the value isn't the same as the value the server is using we won't find the logs directory
        File logsDir = new File(getOutputDir(serverName) + serverName + File.separator + "logs");
        if (!logsDir.exists()) {
            stderr.println(getMessage("server.output.logs.dir.not.found", serverName, logsDir.getAbsolutePath()));
            return RC_SERVER_OUTPUT_NOT_FOUND;
        }

        // The file containing the local connector URL is always in the
        // server's output directory.  Note that the output directory may be
        // different than the user directory, where the server config is.
        File jmxLocalConnectorUrlFile = new File(getOutputDir(serverName) + serverName + File.separator + "logs"
                                                 + File.separator + "state" + File.separator
                                                 + "/com.ibm.ws.jmx.local.address");
        if (jmxLocalConnectorUrlFile.exists() == false) {
            stderr.println(getMessage("local.connector.not.found", serverName));
            return RC_LOCAL_CONNECTOR_URL_NOT_FOUND;
        }

        JMXConnector connector = null;

        try {
            BufferedReader br = new BufferedReader(new FileReader(jmxLocalConnectorUrlFile));
            String urlString = br.readLine();
            br.close();

            if (urlString == null) {
                stderr.println(getMessage("local.connector.url.empty", serverName));
                return RC_UNEXPECTED_ERROR;
            }
            JMXServiceURL url = new JMXServiceURL(urlString);
            connector = JMXConnectorFactory.connect(url);

            MBeanServerConnection con = connector.getMBeanServerConnection();

            // Look up the DDL generation MBean
            ObjectName name = new ObjectName(DDLGenerationMBean.OBJECT_NAME);
            Set<ObjectInstance> objects = con.queryMBeans(name, null);
            if ((objects != null) && (objects.size() > 0)) {
                Iterator<ObjectInstance> i = objects.iterator();
                ObjectInstance o = i.next();
                ObjectName instanceName = o.getObjectName();
                @SuppressWarnings("unchecked")
                Map<String, Serializable> generateResults = (Map<String, Serializable>) con.invoke(instanceName, "generateDDL", new Object[] {}, new String[] {});

                // Check the results from the operation.
                if (generateResults == null) {
                    stderr.println(getMessage("mbean.null.result"));
                    return RC_MBEAN_INVALID_RESULT;
                }

                if (generateResults.containsKey(DDLGenerationMBean.SUCCESS)) {
                    Boolean success = (Boolean) generateResults.get(DDLGenerationMBean.SUCCESS);
                    if ((success == null) || (success.booleanValue() == false)) {
                        stderr.println(getMessage("mbean.bad.result"));
                        return RC_MBEAN_INVALID_RESULT;
                    }
                } else {
                    stderr.println(getMessage("mbean.missing.result"));
                    return RC_MBEAN_INVALID_RESULT;
                }

                String outputDirectory = null;
                if (generateResults.containsKey(DDLGenerationMBean.OUTPUT_DIRECTORY)) {
                    outputDirectory = (String) generateResults.get(DDLGenerationMBean.OUTPUT_DIRECTORY);
                    if ((outputDirectory == null) || (outputDirectory.length() <= 0)) {
                        stderr.println(getMessage("mbean.missing.output.dir"));
                        return RC_MBEAN_INVALID_RESULT;
                    } else {
                        stdout.println(getMessage("mbean.output.dir", outputDirectory));

                        if (generateResults.containsKey(DDLGenerationMBean.FILE_COUNT)) {
                            Integer fileCount = (Integer) generateResults.get(DDLGenerationMBean.FILE_COUNT);
                            if ((fileCount != null) && (fileCount.intValue() == 0)) {
                                stdout.println(getMessage("no.output.generated", serverName));
                            }
                        }
                    }
                } else {
                    stderr.println(getMessage("mbean.missing.output.dir"));
                    return RC_MBEAN_INVALID_RESULT;
                }
            } else {
                stderr.println(getMessage("mbean.not.found", serverName));
                return RC_MBEAN_NOT_FOUND;
            }
        } catch (Throwable t) {
            stderr.println(getMessage("exception.catch", t.toString()));
            t.printStackTrace(stderr);
            return RC_UNEXPECTED_ERROR;
        } finally {
            if (connector != null) {
                try {
                    connector.close();
                    connector = null;
                } catch (Throwable t) {
                    /* Nothing... */
                }
            }
        }

        return 0;
    }
108893
public static void main(String[] args) {
        DEBUG_MODE_V = DebugMode.SCREEN;
        Log.initScreen();
        printVerbose(null, null);
    }
43526
public Exit launch( Class mainClass , String ...args ) {

        jvmArgs = configureArguments(mainClass,args);

        try {
            Runtime rt = Runtime.getRuntime();
            Process pr = rt.exec(jvmArgs);

            // If it exits too quickly it might not get any error messages if it crashes right away
            // so the work around is to sleep
            Thread.sleep(500);

            BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()));
            BufferedReader error = new BufferedReader(new InputStreamReader(pr.getErrorStream()));

            // print the output from the slave
            if( !monitorSlave(pr, input, error) ) {
                if( killRequested )
                    return Exit.REQUESTED;
                else
                    return Exit.FROZEN;
            }

            if( pr.exitValue() != 0 ) {
                return Exit.RETURN_NOT_ZERO;
            } else {
                return Exit.NORMAL;
            }
        } catch (IOException | InterruptedException e) {
            throw new RuntimeException(e);
        }
    }