How to compile and run Java Programs
The Java compiler requires that a source file use the .java extension.
Compiling the Program
To compile the program, say Example.java, specify the name of the source file on the command line,
as shown here:
$ javac Example.java
Running The Program
In Java, all code must reside within a class (say class name is Example). To run the program,
you must use the Java Interpreter, called java and specify the name of the class, as shown here:
$ java Example