Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the best way to write a command-line app in Java? [closed]

Okay, I know there are probably a dozen ways to solve this, but I am looking for either a skeleton app or some sort of tutorial that will explain the best way to write a framework for creating Java-based command-line tools. If my program requires a lot of switches/options/etc., what's the best way to handle all of them?

How do you decide which stuff should be placed into an options/settings file, and which stuff gets put on the command line? Any sort of sample code would be great, that way I can put my time more towards the central focus of my app rather than the command-line plumbing.

like image 380
gonzobrains Avatar asked Jan 22 '11 07:01

gonzobrains


1 Answers

I also suggest looking at JCommander (http://jcommander.org/), written by the author of TestNG. I have used it successfully in many command line applications.

like image 153
jamhan Avatar answered Oct 11 '22 19:10

jamhan