Compiling and running a simple program

Assuming you have the source file HelloWorld.java containing the following simple Java program:

class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, world!") ;
    }
}
   
you can compile the program with:
$ javac HelloWorld.java
   
which should (if all goes well) produce the output class file HelloWorld.class.

You can then run that class file with:

$ java Helloworld