Hello World in Java


Here is everybody's favorite program in Java:

public class Hello {
  public static void main (String args[]) {
    System.out.println ("Hello, World!");
  }
}
To run this program,
  1. Copy this program exactly as written onto a file named Hello.java. (If you are on a PC, you may need to name the file Hello.jav.) Do not give the file some other name.

  2. Compile the file by putting it in the same directory as the compiler and issuing the command
        javac Hello.java
    This should create a file named Hello.class (I'm not sure what it is if you only have 3-character extensions.)

  3. Run the file by issuing the command
        java Hello
    This should print "Hello, World!"
Notes