Java console program

/*
 * put this in a file named CommandLineExample.java
 *
 */

class CommandLineExample
{
    public static void main ( String [] arguments )
    {
        System.out.println("Hello, world");
    }
}

type the following from the command line to compile it:

$ javac CommandLineExample.java

then you can run it from the command line like this:

$ java CommandLineExample

Leave a Comment