Menu

brief tutorial

Chris DeGreef

Our make-believe Java application for this tutorial is the common "Hello World" application. It will print the message "Hello World" on the console. The additional functionality is that we want to control the case of the message. The default will be mixed case. But we will provide a command-line argument to force the message to upper case. This argument will be --upperCase. You will see that it takes only 1 line of extra code to implement Argument to parse the command line.

Test cases

Default
    > HelloWorld
    < Hello World
As upper case
    > HelloWorld --upperCase
    < HELLO WORLD

Java code

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");
    }
}

Related

Wiki: Home

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.