Over a million developers have joined DZone.

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());  
          System.out.println("Hello World");  

see Little Gray Cloud's command-line utility for the JAR file.


The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}