So what does JSAP actually do?

JSAP parses your command line and instantiates objects of types you specify based upon that command line. If you configure JSAP to expect an Integer on the command line, and the user does not provide a String that can be converted to an Integer, JSAP will alert your program to the fact that there was a problem with the command line. If JSAP indicates that your command line was successfully parsed, you are guaranteed an Integer when you request that parameter's value from your program. There's a pretty big (and growing) list of return types suppored by JSAP; you may want to skip right to the javadocs and check it out.

JSAP provides not only for default values for its parameters, but for a cascading chain of values. With a couple extra lines of code, JSAP will, for example:

  1. Parse the command line.

  2. For any omitted parameters, look for values in ~/.yourProgramName.conf

  3. For any still omitted parameters, look for values in /etc/yourProgramName.conf

  4. For any still omitted parameters, use the default values (if any) specified by the developer.