Installing Java

This tutorial gives you step by step instructions on installing the JRE and JDK on either Windows or Linux. Many people believe it is any easy process, but it does require some knowledge of the operating system you are running.

This guide is broken into two sections, one for installing Java and the JDK on Linux, one for installing Java and the JDK on Windows. It isn't a very complex process, but a lot of people get confused when setting paths.

Windows

First, download the JDK from Sun's website: link. Select "JDK 6" from the list of downloads. Accept the license agreement and click "Windows Offline Installation, Multi-language". Make sure to take note of where it is being installed. After it finishes, run it. Follow the installation steps.

Now you need to set the enviroment variables. Go to Start > Settings > Control Panel. In the control panel, select System. Click the advanced tab, then the Enviroment Variables button. Click the PATH entry and click the Edit button. Add the bin directory of wherever you selected JDK to be installed at the beginning. Add a semicolon after it. Example: "C:/Java/jdk1.6.0/bin;". Now, in a command prompt, type "java -version". If it says that the command is not recognized, try going over setting the path again. Otherwise, you have correctly set up Java!

Linux

First, you need to download the JDK from Sun's website: link. Select "JDK 6" from the list of available downloads. Accept the license agreement, then download the "Linux self-extracting file". It's about 60Mb, so it will take a while. Navigate to wherever you downloaded the .bin file to and type: "chmod +x jdk-6-linux-i586.bin && ./jdk-6-linux-i586.bin".

The license agreement should come up. You can either read through it or press q to skip it. Once you have done that, type "yes". It will create a folder called jdk1.6.x. You can move that to wherever you want, but make sure you remember where it is. I will be moving it to ~/Java/.

Now we need to set the PATH variable. I will assume you have moved the JDK folder to ~/Java/ for my example. Add the following to your ~/.bashrc file: "export PATH=~/Java/jdk1.6.0/bin:~/Java/jdk1.6.0/jre/bin:$PATH". To check that it was installed correctly, type "javac -version && java -version". It should show whatever version you downloaded and installed, in this case 1.6.0.