Java command-line argument parser taxonomy

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
JCommander v1.71
annotation, good documentation, custom parser, validation

* Honorable Mention
picocli v3.3
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

* Also-Rans

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

This entry was posted in Software Engineering. Bookmark the permalink.