picocli is different from other Java CLI libraries:

  • It is designed to be included in source form. This lets users run picocli-based applications without requiring picocli as an external dependency.
  • Generates polished and easily tailored usage help, using ANSI colors when the underlying platform supports it.
  • Autocompletion for your Java command line applications on supported platforms

Example usage help message:

Quick overview:

  • Effortless command line parsing - just annotate fields
  • Strongly typed everything - command line options as well as positional parameters
  • full support for both GNU style and POSIX clustered short options (so it handles <command> -xvfInputFile as well as <command> -x -v -f InputFile)
  • An arity model that allows a minimum, maximum and variable number of parameters, e.g, "1..*", "3..5"
  • Subcommands
  • Works with Java 5 and higher
  • Well-structured user manual

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:

  • programmatic API as well as annotations API
  • Dependency Injection container integration
  • JLine integration: delegate to AutoComplete for your command’s Completer implementation
  • interface methods can be annotated with @Option or @Parameters (picocli creates a synthetic implementation that returns the matched options)
  • class methods can be annotated with @Option or @Parameters (so you can validate options and positional parameters)
  • support for @Command methods for extra compact code
  • internationalization with resource bundles

Disclaimer: I am the author.

Answer from Remko Popma on Stack Exchange
🌐
Reddit
reddit.com › r/java › jcommander: an alternative to common cli. ( apache 2.0 license)
r/java on Reddit: JCommander: An Alternative to Common CLI. ( Apache 2.0 license)
January 19, 2014 - After reviewing a number of the options, we settled on JCommander for our command argument parsing, and found it to be very flexible and powerful. My only real recommendations are that you carefully read the documentation, and then keep a copy of the source code around, for the times you need to clarify what the documentation says. ... Looks good. Certainly on par with JOpt Simple, much better than Commons CLI (which was my first huge disappointment with an Apache project).
🌐
Baeldung
baeldung.com › home › java › intro to the apache commons cli
Intro to the Apache Commons CLI | Baeldung
February 20, 2025 - In this article, we discussed the Apache Commons CLI library’s ability to help create CLIs quickly and efficiently in a standardized way. Moreover, the library is concise and easy to understand. Notably, there are other libraries like JCommander, Airline, and Picocli that are equally efficient ...
Discussions

command line - What library should I use for handling CLI arguments for my Java program? - Software Recommendations Stack Exchange
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 More on softwarerecs.stackexchange.com
🌐 softwarerecs.stackexchange.com
January 20, 2015
Java command line parser with subcommands that have similiar options - Software Recommendations Stack Exchange
JArgs Jakarta Commons CLI TE-Code has a command line parsing library. argparser Java port of GNU getopt Args4J JSAP CLAJR CmdLn JewelCli JCommando parse-cmd JCommander plume-lib Options · The website contains links for the above if you want to investigate them further. ... The Apache Commons ... More on softwarerecs.stackexchange.com
🌐 softwarerecs.stackexchange.com
January 2, 2017
picocli - a mighty tiny command line interface
What makes picocli better than: http://jcommander.org/ http://commons.apache.org/proper/commons-cli/ ... the many others already out there? Not being critical, I'm actually curious! More on reddit.com
🌐 r/java
14
69
June 6, 2017
How do I parse command line arguments in Java? - Stack Overflow
Most of the projects listed are essentially abandonware. After going through the list I'd say the big hitters, that are actively maintained and popular, seem to commons-cli, jcommander, args4j, jopt-simple and picocli. More on stackoverflow.com
🌐 stackoverflow.com
🌐
INNOQ
innoq.com › en › blog › 2022 › 01 › java-cli-libraries
Libraries for command-line applications
January 23, 2022 - In contrast to Commons CLI, args4j allows us to use any data type we want. In order to do so we have to implement the OptionHandler class and register it in the OptionHandlerRegistry before parsing.
🌐
Syntax Savvy
learn.syntaxsavvy.dev › langs › tools › commons_cli › introduction_to_apache_commons_cli › what_is_apache_commons_cli
What is Apache Commons CLI? | Syntax Savvy
One of the main differences between JCommander and Apache Commons CLI is that JCommander supports annotations for defining options and arguments, which can make the code more concise and easier to read.
Top answer
1 of 3
14

picocli is different from other Java CLI libraries:

  • It is designed to be included in source form. This lets users run picocli-based applications without requiring picocli as an external dependency.
  • Generates polished and easily tailored usage help, using ANSI colors when the underlying platform supports it.
  • Autocompletion for your Java command line applications on supported platforms

Example usage help message:

Quick overview:

  • Effortless command line parsing - just annotate fields
  • Strongly typed everything - command line options as well as positional parameters
  • full support for both GNU style and POSIX clustered short options (so it handles <command> -xvfInputFile as well as <command> -x -v -f InputFile)
  • An arity model that allows a minimum, maximum and variable number of parameters, e.g, "1..*", "3..5"
  • Subcommands
  • Works with Java 5 and higher
  • Well-structured user manual

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:

  • programmatic API as well as annotations API
  • Dependency Injection container integration
  • JLine integration: delegate to AutoComplete for your command’s Completer implementation
  • interface methods can be annotated with @Option or @Parameters (picocli creates a synthetic implementation that returns the matched options)
  • class methods can be annotated with @Option or @Parameters (so you can validate options and positional parameters)
  • support for @Command methods for extra compact code
  • internationalization with resource bundles

Disclaimer: I am the author.

2 of 3
8

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.

  • picocli (with ANSI colors and autocomplete)
  • JArgs
  • Jakarta Commons CLI
  • TE-Code (it has a command line parsing library.)
  • argparser
  • Java port of GNU getopt
  • Args4J
  • JSAP
  • JOpt Simple
  • CLAJR
  • CmdLn
  • JewelCli
  • JCommando
  • parse-cmd
  • JCommander
🌐
Jabref
devdocs.jabref.org › decisions › 0044-use-picocli-for-jabkit.html
Use Picocli instead of Apache Commons CLI for JabKit | Developer Documentation
As a part of refactoring and migrations ... toolkit (JabKit) was needed. The decision was between continuing to use the existing Apache Commons CLI or migrating to Picocli or JCommander, which are more modern CLI frameworks....
🌐
Blogger
fahdshariff.blogspot.com › 2011 › 12 › args4j-vs-jcommander-for-parsing.html
fahd.blog: Args4j vs JCommander for Parsing Command Line Parameters
December 27, 2011 - In the past, I've always used Apache Commons CLI for parsing command line options passed to programs and have found it quite tedious because of all the boiler plate code involved. Just take a look at their Ant Example and you will see how much code is required to create each option. As an alternative, there are two annotation-based command line parsing frameworks which I have been evaluating recently: ... JCommander I'm going to use the Ant example to illustrate how to parse command line options using these two libraries.
🌐
Jline
jline.org › library integration
Library Integration | JLine
... This example shows how to integrate JLine with Commons CLI to create an interactive shell that parses commands using Commons CLI. JCommander is a Java framework for parsing command-line parameters.
Find elsewhere
🌐
Cleverence
cleverence.com › articles › oracle-documentation › command-line-arguments-the-java-tutorials-4827
Java Command-Line Arguments: Complete Guide with Examples, Libraries, and Best Practices
February 13, 2026 - JCommander provides a similar approach with annotations and a small footprint. Apache Commons CLI is older and more imperative; you define options and parse them via a builder, which some teams prefer for explicitness.
🌐
Maven Repository
mvnrepository.com › open-source › command-line-parsers
Maven Repository: Command Line Parsers
Apache Commons CLI provides a simple API for presenting, processing, and validating a Command Line Interface. Last Release on Nov 13, 2025 · org.jcommander » jcommander Apache · Command line parsing library for Java · Last Release on Oct 5, 2025 · info.picocli » picocli Apache ·
Top answer
1 of 2
2

picocli supports nested subcommands to arbitrary depth.

CommandLine commandLine = new CommandLine(new MainCommand())
        .addSubcommand("cmd1", new ChildCommand1()) // 1st level
        .addSubcommand("cmd2", new ChildCommand2())
        .addSubcommand("cmd3", new CommandLine(new ChildCommand3()) // 2nd level
                .addSubcommand("cmd3sub1", new GrandChild3Command1())
                .addSubcommand("cmd3sub2", new GrandChild3Command2())
                .addSubcommand("cmd3sub3", new CommandLine(new GrandChild3Command3()) // 3rd
                        .addSubcommand("cmd3sub3sub1", new GreatGrandChild3Command3_1())
                        .addSubcommand("cmd3sub3sub2", new GreatGrandChild3Command3_2())
                                // etc
                )
        );

You may also like its usage help with ANSI styles and colors.

Note that usage help lists the registered subcommands in addition to options and positional parameters.

The usage help is easily customized with annotations.

  • annotation-based
  • git-style subcommands
  • nested sub-subcommands
  • strongly typed option parameters
  • strongly typed positional parameters
  • customizable type conversion
  • multi-value options
  • intuitive model for how many arguments a field consumes
  • allows any option prefix
  • fluent API
  • POSIX-style clustered short options
  • GNU style long options
  • ANSI colors in usage help
  • customizable usage help
  • single source file: include as source to keep your application a single jar
2 of 2
1

Which command line arguments parser supports these requirements?

From the limited information in your question the following appear to match your needs.


JOpt Simple

JOpt Simple is a Java library for parsing command line options, such as those you might pass to an invocation of javac.

In the interest of striving for simplicity, as closely as possible JOpt Simple attempts to honor the command line option syntaxes of POSIX getopt() and GNU getopt_long(). It also aims to make option parser configuration and retrieval of options and their arguments simple and expressive, without being overly clever.

The JOpt Simple web page also lists a number of other Java Commandline Parsers which may also be suitable if JOpt Simple is not sophisticated enough for you:

Here are some libraries that perform the same duties as JOpt Simple:

JArgs
Jakarta Commons CLI
TE-Code has a command line parsing library.
argparser
Java port of GNU getopt
Args4J
JSAP
CLAJR
CmdLn
JewelCli
JCommando
parse-cmd
JCommander
plume-lib Options

The website contains links for the above if you want to investigate them further.

Source JOpt Simple


Apache Commons CLI

The Apache Commons CLI library provides an API for parsing command line options passed to programs. It's also able to print help messages detailing the options available for a command line tool.

Commons CLI supports different types of options:

  • POSIX like options (ie. tar -zxvf foo.tar.gz)
  • GNU like long options (ie. du --human-readable --max-depth=1)
  • Java like properties (ie. java -Djava.awt.headless=true -Djava.net.useSystemProxies=true Foo)
  • Short options with value attached (ie. gcc -O2 foo.c)
  • long options with single hyphen (ie. ant -projecthelp)

A typical help message displayed by Commons CLI looks like this:

usage: ls
 -A,--almost-all          do not list implied . and ..
 -a,--all                 do not hide entries starting with .
 -B,--ignore-backups      do not list implied entried ending with ~
 -b,--escape              print octal escapes for nongraphic characters
    --block-size <SIZE>   use SIZE-byte blocks
 -c                       with -lt: sort by, and show, ctime (time of last
                          modification of file status information) with
                          -l:show ctime and sort by name otherwise: sort
                          by ctime
 -C                       list entries by columns

Source Apache Commons CLI

🌐
GitHub
github.com › timtiemens › javacommandlineparser
GitHub - timtiemens/javacommandlineparser: Taxonomy of Java Command Line Parser Libraries · GitHub
Java Command-Line Interfaces (Part N of 30) number 1 covers Commons-CLI, number 2 covers args4j, number 7 covers JCommander, number 21 covers Airline, number 28 covers getopt4j, and number 30 is a summation and "5 most likely to succeed" (commons-CLI, args4j, JCommander, JewelCLI, picocli) section.
Author   timtiemens
🌐
Apache Commons
commons.apache.org › cli
Apache Commons CLI – Apache Commons CLI
November 8, 2025 - Apache Commons, Apache Commons CLI, Apache, the Apache logo, and the Apache Commons project logos are trademarks of The Apache Software Foundation.
🌐
Reddit
reddit.com › r/java › picocli - a mighty tiny command line interface
r/java on Reddit: picocli - a mighty tiny command line interface
June 6, 2017 - http://jcommander.org/ http://commons.apache.org/proper/commons-cli/ ... the many others already out there? Not being critical, I'm actually curious! acisternino · • · 9y ago · • Edited · 9y ago · Personally: vs. JCommander: I don't like using annotations for parsing the CLI.
🌐
TutorialsPoint
tutorialspoint.com › commons_cli › commons_cli_quick_guide.htm
Apache Commons CLI - Quick Guide
The Apache Commons CLI are the components of the Apache Commons which are derived from Java API and provides an API to parse command line arguments/options which are passed to the programs.
🌐
John Yeary
johnyeary.com › 2018-11-09-simplifying-command-line-processing.html
Simplifying Command Line Processing - John Yeary
November 9, 2018 - I like many of you have spent many hours using Apache Commons CLI to create command line options. It does a great job. As the number of options, or groups increases, the framework begins to show its rough edges. A tool called JCommander which I mentioned in my post Useful Java Frameworks really ...
🌐
GitHub
github.com › remkop › picocli › wiki › CLI-Comparison
CLI Comparison
December 11, 2019 - Picocli is a modern framework for building powerful, user-friendly, GraalVM-enabled command line apps with ease. It supports colors, autocompletion, subcommands, and more. In 1 source file so apps can include as source & avoid adding a dependency. Written in Java, usable from Groovy, Kotlin, ...
Author   remkop
🌐
Opensource.com
opensource.com › article › 21 › 8 › java-commons-cli
Parse command options in Java with commons-cli | Opensource.com
August 13, 2021 - There are several ways to parse options in Java. My favorite is the Apache Commons CLI library, called commons-cli for short.