For writing command line applications in Java, what is the best library for parsing and managing arguments and paramenters?
Note: this question is an updated version of this closed question on Stack Overflow.
picocli is different from other Java CLI libraries:
Example usage help message:
<command> -xvfInputFileas well as
<command> -x -v -f InputFile)
Usage help is the face of your application, so be creative and have fun!
Picocli is also actively maintained. Since the original post, many new features were added, for example:
@Parameters(picocli creates a synthetic implementation that returns the matched options)
@Parameters(so you can validate options and positional parameters)
@Commandmethods for extra compact code
Disclaimer: I am the author.
I recommend JOpt Simple. It 'attempts to honor the command line option syntaxes of POSIX getopt() and GNU getopt_long().' It has community traction and notably is the command line parsing lib of choice for the OpenJDK itself.
For comparison, here's a relatively up to date (as of Jan 2015) list of related libraries that serve the same purpose.
My choice goes to JCommander.
As of Oct 2016, have to start a new project and finally decided to do arguments the smart way. Just compared Jopt-simple, JCommander, args4j.
Choice reason: only JCommander and args4j have annotations, only JOpt-simple and JCommander have a great tutorial.