Installing Java on Linux

Installing Java on Linux


Download the latest version of JDK from I have downloaded jdk-1_5_0_01-Linux-i586.bin for this tutorial.
Change to the directory where you downloaded the JDK ( I downloaded it in my home directory /home/maddy) and make the self-extracting binary executable:
chmod +x jdk-1_5_0_01-Linux-i586.bin

Run the self-extracting binary, this will display the License agreement text and will ask you to accept the agreement:
Above command should create a directory called jdk1.5.0_01 in the /home/maddy directory. Move the JDK directory to /opt . Here is the command used:
mv jdk1.5.0_01 /opt
Set the JAVA_HOME environment variable, by modifying /etc/profile so it includes the following:

export JAVA_HOME

save /etc/profile file. Then run following command to take effect.
source /etc/profile
Check to make sure JAVA_HOME is defined correctly using the command below. You should see the path to your Java JDK.
Output should be
Now need to set out new Java by default through the alternative utility. First, we will install alternative java then we will configure it make it as default java.
To install java using the alternative command:
alternatives –install /usr/bin/java java /opt/jdk1.5.0_01/bin/java 2
Now need to configure it to make it as default Java location:

alternatives -config java

Above command will given output. There we will have to select latest java location.
[root@alpeshpc opt]#alternatives –config java

There are 3 programs which provide ‘java’.

Selection Command
* 1 /usr/lib/jvm/jre-1.4.2-gcj/bin/java
2 /opt/jdk1.5.0_01/bin/java

Give there number 2, then press enter.

Thats it.

Leave a Reply

Your email address will not be published. Required fields are marked *