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:;"

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 ; \

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

Post a comment or leave a trackback: Trackback URL.

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: