I used GnuParser() instead of DefaultParser() and it works well.CommandLineParser parser = new GnuParser();
Update : In version 1.3.1 of CLI, GnuParser() is now deprecated. So I simply added import org.apache.commons.cli.DefaultParser;
and now I use CommandLineParser parser = new DefaultParser();
And all is fine!
What version of CLI are you using? DefaultParser wasn't added until the 1.3 snapshot.
http://commons.apache.org/proper/commons-cli/apidocs/org/apache/commons/cli/DefaultParser.html
I've encountered the same problem while following same usage guide with commons-cli 1.2 and found the following available parsers:
org.apache.commons.cli.BasicParserorg.apache.commons.cli.GnuParserorg.apache.commons.cli.PosixParserThey all extends the org.apache.commons.cli.Parser and only implement the flatten method. You can check Parser's javadoc (and implementing parsers) for more information.
this DefaultParser class is of Apache CLI 1.3 so for using this you have to update your class path with jar varsion 1.3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With