Every once in a while, at the beginning of a new project, I start the search for a command-line argument parsing library in Java. This post shows the results of examining the field as of mid 2018. This post serves both as a “which to use” and as a “which have been evaluated, and found wanting” guide.
* Best So Far
annotation, good documentation, custom parser, validation
* Honorable Mention
annotation, good documentation — documentation looks suspiciously like it is patterned after JCommander
* Pretty Good
field-based, annotation-based, unclear if “–long-Name” is supported
annotation-based, interface-based but can be instance-based with setters, has short and long names
Key-Value – the opposite of a good library. Many of the libraries below share this same deficiency.
single “parse” call with array of options, Key-Value get value where key is the option
Jakarta Commons CLI
like JArgs, except key is “String”, not option object
create individual options, where options are “holders”, parse() into the holders
old (2008), not well documented
it generates .java, but still requires an additional .jar