How to Install Java in a GNU/Linux System

This page explains how to install the Java Runtime Environment in a GNU/Linux system. If you wish to link to this page, please use this address: http://purl.oclc.org/net/klivo/javalinux


First, you should check your system resources. The basic requirements are an Intel-based system, with a minimum of 64 megabytes of memory and about 60 megabytes of free disk space. Details can be found here.

The next step is to download the Java installation program. Go to the Java homepage, http://java.com/, and click on the large blue 'Free Java Download' button.
The server will send you to a download page for Linux, which gives a choice of four files. For this tutorial we will download and install the second file, Linux (self-extracting file).

When you click on the link, your browser will prompt you to verify the download. Click on 'Save it to disk'. Your system may ask you where you want to save the file, or simply save it in your home folder. We'll assume that the downloaded file is jre‑6u12‑linux‑i586.bin, and that it's been saved into your home folder, /home/yourname.


Next, you need to open the command line interface (also called 'command shell'). If you don't have a desktop link, like the ones shown on the left, you can open the command line interface from the Application menu:

Applications > Accessories > Terminal

You will need to acquire administrator (root) privileges in order to continue. In the Terminal window, type the command:

su    (Followed by <enter>, of course.)

Linux will prompt you for the root password. After correctly entering the password, type in the following commands:

mv jre‑6u12‑linux‑i586.bin /usr/java
(To move the installation program to a suitable location.)

cd /usr/java
(To move to the location where the installation program is located.)

chmod 700 jre‑6u12‑linux‑i586.bin
(Change mode, to enable program execution.)

./jre‑6u12‑linux‑i586.bin      (To run the installation program.)

Linux and Unix systems distinguish between upper and lower case. Enter commands exactly as shown.

When the installation program starts running, it will display a license agreement. Go the the end of the text by pressing the enter key. The program will ask whether you accept the conditions. Enter 'y' for yes.


The program will start to unpack and copy files.

When it finishes, type ls to list the files. Notice that there is a new subfolder, called jre1.6.0_12

You can delete the installation program, if you wish:

rm ‑f jre‑6u12‑linux‑i586.bin

Finally, it is necessary to adjust your environment variables. In the folder /etc there is a file called profile. Edit this file and add the following two lines at the end:

JAVA_HOME=/usr/java/jre1.6.0_12; export JAVA_HOME;
PATH=$JAVA_HOME/bin:$PATH; export PATH;

(Again, the distinction between upper and lower case is important.)

In order for your system to 'see' the changes, you need to log out and log in again. After logging in again, open a command shell window and enter:

java ‑version

If your installation was successful, the system should respond with:

java version "1.6.0_12"


Finished.