17

Hello I am working on command line application which can accepts command line argument like

app -port 8888 -filename d:\xyz\xyz.pdf -dest d:\pqr

I am looking for function which can return me pair of option and it corresponding value like getopt in c.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Prasad S Deshpande
  • 1,362
  • 4
  • 15
  • 35
  • 2
    possible duplicate of [Java library for parsing command-line parameters?](http://stackoverflow.com/questions/1200054/java-library-for-parsing-command-line-parameters) – Sean Reilly Aug 03 '12 at 11:57
  • Does this answer your question? [How do I parse command line arguments in Java?](https://stackoverflow.com/questions/367706/how-do-i-parse-command-line-arguments-in-java) – GreenGiant Jul 12 '22 at 15:05

1 Answers1

14

There are quite a few command line parser libraries for Java out there.

A recent (as of late 2019) command line parser with a lot of momentum and features is picocli.

Some older, popular ones are commons-cli (quite old), args4j and JCommander.

Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
Stefan Ferstl
  • 5,135
  • 3
  • 33
  • 41