Parsing the command line.
Prev | Chapter 4. How It Works | Next

## Parsing the command line.

The `JSAP` object provides two `parse()` methods to parse a command line. The first takes an array of `String`s as its only parameter; in most uses of `JSAP`, this will simply be the `args[]` array supplied by the JVM to your `main()` method.

The second `parse()` method takes a single `String` as its only parameter. This method first tokenizes the `String` into an array, much like the operating system does for the JVM in providing your `main()` method with the `args[]` array, then calls the `parse(String[])` method described above.

Both of these methods return a `JSAPResult` object encapsulating the parsed command line.

`SimpleJSAP` is a subclass of `JSAP`, and works analogously: however, if an error is detected, or if the user specified `--help`, a full usage and help message is printed automatically. You can learn whether the message has been printed or not by invoking the method `messagePrinted()` on the `SimpleJSAP` instance just after parsing: if it returns true, you shoud usually terminate the program execution.

Prev | Up | Next
Registering your parameters with JSAP. | Home | Using the JSAPResult