To start off, the smallest Java program there is.

class HelloWorld {
  public static void main(String args[]) {
    System.out.println("Hello World!");
  }
}

To compile and run from the command line:

  javac HelloWorld.java
  java HelloWorld