9

I have used getopt in Python and was hoping there would be something similar in Java.

Please give a reason why your answer is better than the others.

Liam
  • 19,819
  • 24
  • 83
  • 123
  • 1
    btw, optparse.OptionParser is a preferred way in Python. – jfs Oct 16 '08 at 09:36
  • possible duplicate of [Is there a good command line argument parser for Java?](http://stackoverflow.com/questions/367706/is-there-a-good-command-line-argument-parser-for-java) – Thilo Jul 07 '11 at 04:15

4 Answers4

6

Commons CLI

C. K. Young
  • 219,335
  • 46
  • 382
  • 435
  • I like this one so far as it was quite easy to get up and running with a simple download. The 50 line demo is all I needed to get started, and I easily found that I could parse POSIX-style or GNU-style. – Liam Oct 16 '08 at 11:00
  • 2
    this is a horrible answer, Java Simple Argument Parse (JSAP) is a much better library. This is a hideous library and is really deprecated. –  Jan 05 '10 at 22:15
  • So, how is JSAP better than Commons CLI? The only differences I see are: 1. Extensible type handlers (Commons CLI plans to make them extensible, but currently only a fixed set is supported), 2. ability to default values from configuration files. – C. K. Young Jan 05 '10 at 22:20
6

I use Jewelcli and it's quite good.

You can also find a discussion of different available libraries here.

bernardn
  • 1,701
  • 5
  • 19
  • 23
2

Look at Java Simple Argument Parser. Very mature and feature complete argument parser for Java. JSAP

2

https://github.com/kohsuke/args4j -- has pretty good features PLUS MIT license

Chadwick
  • 12,555
  • 7
  • 49
  • 66
anjanb
  • 12,999
  • 18
  • 77
  • 106