| Start | ||||
|---|---|---|---|---|
| Argument processing using GWT ToolBase If you want to parse more complex command-line arguments, e.g. with optional parameters, than the best is to use google's GWT approach. All classes are public available at: An example for handling the command-line
|
||||
| Processing arguments by hand When the command-line syntax for an application is simple, it is reasonable to do the command argument processing entirely in custom code. In this example, we will present a series of simple case studies. In each case, the code will produce error messages if the arguments are unacceptable, and then call A command with no argumentsIn this case-study, the command requires no arguments. The code illustrates that A command with two argumentsIn this case-study, the command requires at precisely two arguments. Note that if we neglected to check A command with "flag" options and at least one argumentIn this case-study, the command has a couple of (optional) flag options, and requires at least one argument after the options. As you can see, processing the arguments and options gets rather cumbersome if the command syntax is complicated. It is advisable to use a "command line parsing" library; see the other examples. Syntax
Parameters
RemarksWhen a regular Java application is launched using the Unfortunately, the Java SE class libraries do not provide any direct support for command argument processing. This leaves you two alternatives:
This Topic will attempt to cover some of the more popular 3rd-party libraries. For an extensive list of the alternatives, see this answer (opens new window) to the StackOverflow Question "How to parse command line arguments in Java?" (opens new window). |
Read Article
https://develop.horje.com/learn/1434/reference