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.
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:
Quick overview:
<command> -xvfInputFile
as well as <command> -x -v -f InputFile
)"1..*"
, "3..5"
Usage help is the face of your application, so be creative and have fun!
Update:
Picocli is also actively maintained. Since the original post, many new features were added, for example:
@Option
or @Parameters
(picocli creates a synthetic implementation that returns the matched options)@Option
or @Parameters
(so you can validate options and positional parameters)@Command
methods for extra compact codeDisclaimer: 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.