Apache Commons CLI Example

HelpFormatter help = new HelpFormatter();

        Options options = new Options();
        options.addOption("h", "help", false, "print program usage");
        options.addOption("n", "name", true, "sets job name");
        CommandLineParser parser = new BasicParser();
        CommandLine cline;
        try {
            cline = parser.parse(options, args);
            args = cline.getArgs();
            if (args.length < 1) {
                help.printHelp(CMDLINE, options);
                return -1;
        } catch (ParseException e) {
            help.printHelp(CMDLINE, options);
            return -1;
        String name = null;
        try {
            if (cline.hasOption('n'))
                name = cline.getOptionValue('n');
                name = "wildnove.com - Tutorial MultiTableOutputFormat ";

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s