Thursday, August 23, 2012

How to Install and Configure JDK on Linux


Installing Sun JDK on Linux Installing Sun JDK on Linux. 

Downloading
 Download the latest version of JDK from http://www.java.sun.com. I have downloaded jdk-1_5_0_01-linux-i586.bin for this tutorial.

Installing
Change to the directory where you downloaded the SDK ( I downloaded it in my home directory /home/deepak) 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:
./jdk-1_5_0_01-linux-i586.bin

Above command should create a directory called jdk1.5.0_01 in the /home/pankaj directory. Move the SDK directory to /usr/java/ .Create /usr/java if it doesn't exist. Here is the command used:
mv jdk1.5.0_01 /usr/java

Set the JAVA_HOME environment variable, by modifying /etc/profile so it includes the following:
JAVA_HOME="/usr/java/jdk1.5.0_01"
export JAVA_HOME


/etc/profile is run at startup and when a user logs into the system, so you will need to log out and log back in for JAVA_HOME to be defined.

Check to make sure JAVA_HOME is defined correctly using the command below. You should see the path to your Java SDK.

echo $JAVA_HOME

Output should be

/usr/java/jdk1.5.0_01

1 comment: