Is there library support for parsing command line arguments in Java?
Preferably in the APIs that are with the default JRE, and supporting UNIX-like arguments
Something along the lines of PERL's GetOpt?
Is there library support for parsing command line arguments in Java?
Preferably in the APIs that are with the default JRE, and supporting UNIX-like arguments
Something along the lines of PERL's GetOpt?
I havn't been able to find a perfect one yet. I've experimented with two so far:
Options This one worked alright for me, but I found it complicated and not everything worked as I expected. Plus, I felt that the examples provided didn't help me as much as I wanted, in my case at least. Nevertheless, this one is quite powerful.
GNU getOpt This is a java port straight from the GNU. When I used it, it wasn't catching all the arguments that I had wanted. However, it could of been something on my end, so give it a try.
AFAIK, the standard APIs don't contain such features, but there are several 3rd party options available. See this page for links and feature summaries:
Open Source Command Line Interpreters in Java
Edit: Here's a related question: Are there good Java libraries that facilitate building command-line applications? (Looking at the title it seems broader than this, but a lot of the discussion focuses on argument parsing.)