Installing Java on Linux

March 15, 2012 | Linux

Java on Linux

Lets see how to install Java on Ubuntu.
On all other Unix flavored systems, the procedure will be more or less same as we’re using terminal Unix commands to install JDK.

Download JDK from here:
http://www.oracle.com/technetwork/java/archive-139210.html#javase

Suppose say JDK is downloaded to ‘Downloads‘ folder

Change directory to Downloads folder

% cd ~/Downloads

Change the execute permissions of downloaded JDK bin file:

% chmod a+x jdk-6u30-linux-i586.bin

Go to the directory where you want to install JDK
Suppose say the desirable directory is ‘/usr/bin’

% cd /usr/bin

Install the JDK directly by running the bin file

% ~/Downloads/jdk-6u30-linux-i586.bin

Thats all JDK is installed on your Linux/Ubuntu machine.

You can check the directory where the JDK is installed by running

% ls -ltr

The latest directoy starting with ‘jdk’ is the one where JDK is installed.
For e.g.:

drwxr-xr-x 10 root   root       4096 2012-03-09 08:45 jdk1.6.0_30

Troubleshooting:
You may get while executing the bin:
cannot access `install.sfx.4273′: No such file or directory
kind of error
Reason: You don’t have permissions to run this bin file
Solution: Run the command as root:

% sudo ~/Downloads/jdk-6u30-linux-i586.bin

Set JAVA_HOME:
Run the following command in order to add Java environment variable:

% echo "export JAVA_HOME=/usr/bin/jdk1.6.0_30" >> ~/.bashrc
% echo "export PATH=$JAVA_HOME/bin:$PATH" >> ~/.bashrc

Tags: ,

Leave a Reply

If you have a Tip, Comment, Article or anything you want to share, please send it to: i@poisure.com