Sunday, August 2, 2009

Installing Java on Linux

This Post describes how to install and set pathvariable for java in linux

Step1: Get rpm packages for Java

Download appropriate package from http://java.sun.com/javase/downloads/index.jsp

Step2: Install Java

Make the downloaded bin file executable

#chmod +x jdk-6u14-linux-x64-rpm.bin
#./jdk-6u14-linux-x64-rpm.bin

By default java will get installed on /usr/java/ , in this case /usr/java/jdk1.6.0_14


Step3: Set Java_Home and add it to Path Variable

Create a file /etc/profile.d/java

# touch /etc/profile.d/java
# chmod +x /etc/profile.d/java

#vi /etc/profile.d/java

#***** Set Env Variables for Java
JAVA_HOME=/usr/java/jdk1.6.0_14
export JAVA_HOME
export PATH=$JAVA_HOME/bin:$PATH

Logout from shell to get this updated


Note: [ Instead of creating /etc/profile.d/java we can always update the variables in /etc/profile ]

Step4: Test the installation

# java -version
java version "1.6.0_14"
Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode)

No comments:

Post a Comment