DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Command-line Parsing In Java
/**
* This will print the message “Hello World†on the console. The additional
* functionality is that you can control the case of the message.
* The default will be mixed case. A command-line argument
* can force the message to upper case. This argument is --upperCase.
*/
public class HelloWorld {
public boolean asUpperCase;
static public int main (String[] args) {
CmdLine.create("-t boolean -k upperCase --variable asUpperCase")
.parse(this, args);
if (asUpperCase)
System.out.println("Hello World".toUpperCase());
else
System.out.println("Hello World");
}
}
see Little Gray Cloud's <a href="http://littlegraycloud.com/software-for-the-developer/argument-command-line-options/tutorial/">command-line</a> utility for the JAR file.





