go to  ForumEasy.com   
JavaPro
   Home  |  MyForum  |  FAQ  |  Archive    You are not logged in. [Login] or [Register]  
Forum Home » Amazon AWS » Install JAVA JDK on AWS EC2 instance
Email To Friend  |   Set Alert To This Topic Rewarding Points Availabe: 0 (What's this) New Topic  |   Post Reply
Author Topic: Install JAVA JDK on AWS EC2 instance
Linux
member
offline   
 
posts: 41
joined: 01/24/2011
from: San Jose, CA
  posted on: 10/12/2011 07:58:43 PM    Edit  |   Quote  |   Report 
Install JAVA JDK on AWS EC2 instance
Download a JDK RPM from http://download.java.net/jdk6/. Look for "RPM" under "Linux". Copy the link address to "jdk-6u29-ea-bin-b08-linux-i586-23_sep_2011-rpm.bin" and then use curl.

# mkdir /usr/local/java
# cd /usr/local/java
# curl http://download.java.net/jdk6/6u29/promoted/b08/binaries/
jdk-6u29-ea-bin-b08-linux-i586-23_sep_2011-rpm.bin > jdk-rpm.bin


Then 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-rpm.bin
# ./jdk-rpm.bin 
# /usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_29/bin/java 100
# /usr/sbin/alternatives --install /usr/bin/jar jar /usr/java/jdk1.6.0_29/bin/jar 100
# /usr/sbin/alternatives --install /usr/bin/javac javac /usr/java/jdk1.6.0_29/bin/javac 100
# /usr/sbin/alternatives --config java


Type the following command to verify the exact path to which java executable under UNIX / Linux:
# which java
/usr/bin/java

Also to make sure the version is correct:
# java -version
java version "1.6.0_29-ea"
Java(TM) SE Runtime Environment (build 1.6.0_29-ea-b08)
Java HotSpot(TM) Client VM (build 20.4-b01, mixed mode, sharing)

 Profile | Reply Points Earned: 0
Linux
member
offline   
 
posts: 41
joined: 01/24/2011
from: San Jose, CA
  posted on: 10/12/2011 08:54:23 PM    Edit  |   Quote  |   Report 
Set environment variable JAVA_HOME under Linux
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.
 Profile | Reply Points Earned: 0
AwsEC2
member
offline   
 
posts: 23
joined: 08/28/2012
from: CA
  posted on: 08/28/2012 02:21:51 PM    Edit  |   Quote  |   Report 
Install JDK 64-bit version
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 WinSCP

Copy jdk-6u34-linux-x64-rpm.bin onto /usr/local/java/

Step 3). Install JDK

Then 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 link

The 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)


 Profile | Reply Points Earned: 0
AwsEC2
member
offline   
 
posts: 23
joined: 08/28/2012
from: CA
  posted on: 08/28/2012 06:59:03 PM    Edit  |   Quote  |   Report 
Set environment variable JAVA_HOME
After changing any environment settings, you have to log off to let the changes take effect.

Quick notes on vi:

1) Start vi
vi <filename>

2) Browse
:$ -- Last line
:0 -- First line

3) Insert
i <changes> Esc

4) Copy-Paste
yy -- copy current line
yNy -- copy N lines
p -- paste

5) Search
/<str> -- search for <str>

6) Exit vi:
:x -- to eXit (save+quit)
:q -- to quit
:q! -- to quit without save


 Profile | Reply Points Earned: 0

 
Powered by ForumEasy © 2003-2005, All Rights Reserved. | Privacy Policy | Terms of Use
 
Get your own forum today. It's easy and free.