What is the best way to write a command line application in Java?


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.

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.