RSS

Install java in centos

28 Sep

1. download bin file using below command

> wget http://download.oracle.com/otn-pub/java/jdk/6u27-b07/jdk-6u27-linux-i586.bin

If the link is not working,  Please use the below link, If you need latest one download it.

http://www.oracle.com/technetwork/java/javase/downloads/index.html

2. After download complete it look like

jdk-6u26-linux-x64.bin?e=1312191174&h=c5f0b98f8ea25aca97f3b53be8497570

so we need to rename the file using below command,

> mv  jdk-6u26-linux-x64.bin?e=1312191174&h=c5f0b98f8ea25aca97f3b53be8497570  jdk-6u4-linux-x64.bin

3. Move the self-extracting file to where you want to install it and extract the file

> mv jdk-6u4-linux-x64.bin /opt/

> cd /opt

> sh jdk-6u4-linux-x64.bin

4. Create a bash script to set JAVA_HOME and add Java executables to the path.

> vim /etc/profile.d/java.sh

export JAVA_HOME=/opt/jdk1.6.0_26/
export PATH=$JAVA_HOME/bin:$PATH

5. Source you new script so exports take effect

> source /etc/profile.d/java.sh

6. Setup Java to be used by the alternatives system (if you want, or if you have an existing install of Java on your box.

> alternatives –install /usr/bin/java java /opt/jdk1.6.0_04/bin/java 2

7. Set this new alternatives as the current configuration

> alternatives –config java

Result:

There are 3 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
   1           /usr/lib/jvm/jre-1.4.2-gcj/jav
 + 2           /usr/java/jdk1.6.0_20/bin/java
*  3           /usr/lib/jvm/jre-1.6.0-openjdk/bin/java

Just note down the number you are going to use.

2 — alternative number noted in step 6.

After complete the process just conform using

>java -version

 
Leave a comment

Posted by on September 28, 2011 in CentOS, Installations, Java

 

Tags: , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: