Once you've installed openjdk on your Pi you can quickly write, compile, and run this little example to check it is working correctly:
nano Test.java
Enter the following code: (Ctrl-O Ctrl-X to save and exit from nano editor)
public class Test
{
       public static void main(String[] args)
       {
               System.out.println("Hello World from Raspberry Pi");
       }
}
Now compile it:
javac Test.java
Now run it:
java Test
Hello World from Raspberry Pi