The best compiler to use is probably the JDK, short for Java Development Kit. You need version 5.0, also known as 1.5.0, or better of the JDK. To check what you have already, try typing java -version to see what version run time environment (JRE) you have and javac -version to see if you have a matching version of the compiler (it may not give a version number if it is old)
To install JDK on a PC, see the department's Java Resources page. In brief, go to the Java site: java.sun.com, download the JDK version 5.0 or better, and follow the installation instructions to change the PATH environment variable. Also download the documentation, if you want to be able to use Java while not online. To try out the compiler, download or copy-and-paste the program Test.java:
class Test
{
static public void main (String[] args)
{
System.out.println ("Hi");
}
}
Start up a terminal window or command prompt window (on Windows, go to the Start menu, then if necessary the Programs menu, and if necessary the Accessories menu, then choose Command Prompt or DOS Prompt). Change to the directory with the program in it, using the cd command. Use javac to compile the program, and java to run it (you type the green text):
> javac Test.java > java Test Hi
The javac command compiles the program, displays error messages if there are any problems, and creates a file called Test.class. This is the one used by the java command. Common mistakes are to use javac without the .java ending, or to use java with the .java ending. Try these now and see what error messages you get, so you will recognise the problem later (everybody does it sometime):
> javac Test (mistake) > java Test.java (mistake)