Subject: Install JDK 64-bit version
Author: AwsEC2
In response to: Set environment variable JAVA_HOME under Linux
Posted on: 08/28/2012 02:21:51 PM
Download a JDK RPM from http://www.oracle.com/technetwork/java/javase/downloads/index.html. Look for "linux-x64-rpm" and download JDK 64-bit version from http://download.oracle.com/otn-pub/java/jdk/6u34-b04/jdk-6u34-linux-x64-rpm.bin
Step 1). Make the folder available
# mkdir /usr/local/java
# cd /usr/local
# chmod 777 java
Step 2). Upload the downloaded JDK by WinSCPCopy
jdk-6u34-linux-x64-rpm.bin onto /usr/local/java/
Step 3). Install JDKThen follow the instructions on
http://alwajdi.blogspot.com/2007/12/how-to-install-snns-jdk-in-fedora-8.html to install the downloaded JDK.
# chmod 755 jdk-6u34-linux-x64-rpm.bin
# ./jdk-6u34-linux-x64-rpm.bin
Note: The installed JDK jdk1.6.0_34 will be under /usr/java/ Step 4). Override the default JDK linkThe AWS-Linux instance comes with a built-in JDK. You can find it out by:
$ java -version
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.3) (amazon-52.1.11.3.45.amzn1-x86_64)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
Which is OpenJDK 64-Bit Server VM.
Where does it locate? You can find it out by:
$ which java
/user/bin/java
How to override this default built-in JDK? You can do it by
alternatives:
alternatives --install <link> <name> <path> <priority>
# /usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_34/bin/java 100
# /usr/sbin/alternatives --install /usr/bin/jar jar /usr/java/jdk1.6.0_34/bin/jar 100
# /usr/sbin/alternatives --install /usr/bin/javac javac /usr/java/jdk1.6.0_34/bin/javac 100
# /usr/sbin/alternatives --config java
Step 5). Just make sure everything is correct
# java -version
java version "1.6.0_34"
Java(TM) SE Runtime Environment (build 1.6.0_34-b04)
Java HotSpot(TM) 64-Bit Server VM (build 20.9-b04, mixed mode)
>
> On 10/12/2011 08:54:23 PM
Linux wrote:
There are three ways.
1). Set for current environment
$ export JAVA_HOME=/usr/java/jdk1.6.0_29
Type the following to verify
$ echo $JAVA_HOME
/usr/java/jdk1.6.0_29
2). Set for single user
Login to your account and open .bash_profile or .bashrc file
$ vi ~/.bash_profile
Type the following:
export JAVA_HOME=/usr/java/jdk1.6.0_29
Save and close the file. Just logout and login back to see the change.
$ echo $JAVA_HOME
/usr/java/jdk1.6.0_29
3). Set for all users
Login as root user and setup the global config in /etc/profile OR /etc/bash.bashrc file for all users:
# vi /etc/profile
Type the following:
export JAVA_HOME=/usr/java/jdk1.6.0_29
Save and close the file.
References: