Oracle/Sun JDK on EC2 Amazon Linux

Here is a cheat sheet on how to get an Amazon Linux EC2 instance tricked out with Oracle JDK instead of the default OpenJDK.

Remove OpenJDK without removing dependencies:
$ sudo rpm --erase --nodeps java-1.6.0-openjdk java-1.6.0-openjdk-devel
$ sudo rpm --erase --nodeps java-1.6.0-openjdk java-1.6.0-openjdk-devel

Get oracle/sun jdk:
$ wget --no-check-certificate --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2Ftechnetwork%2Fjava%2Fjavase%2Fdownloads%2Fjdk-7u3-download-1501626.html;" http://download.oracle.com/otn-pub/java/jdk/7u25-b15/jdk-7u25-linux-x64.rpm

Install new jdk
$ sudo yum install jdk-7u25-linux-x64.rpm

Create new symlinks and switch to them
$ for i in /usr/java/jdk1.7.0_25/bin/* ; do \
f=$(basename $i); echo $f; \
sudo alternatives --install /usr/bin/$f $f $i 20000 ; \
sudo update-alternatives --config $f ; \
done

Create symlink to JDK for use by aws tools:

$ cd /etc/alternatives
$ sudo ln -sfn /usr/java/jdk1.7.0_25 java_sdk
$ cd /usr/lib/jvm
$ sudo ln -sfn /usr/java/jdk1.7.0_25/jre jre

Advertisements
Post a comment or leave a trackback: Trackback URL.

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: