Over a million developers have joined DZone.

Command-line Parsing In Java

DZone's Guide to

Command-line Parsing In Java

Free Resource

 * 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.


Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

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 }}