Skip to content

Instantly share code, notes, and snippets.

@mohataher
Forked from rtfpessoa/java-8-ami.md
Last active August 2, 2016 16:12
Show Gist options
  • Save mohataher/60ccc1c10c4974e5496b to your computer and use it in GitHub Desktop.
Save mohataher/60ccc1c10c4974e5496b to your computer and use it in GitHub Desktop.
[Guide] Install Sun Java 8 on Amazon EC2 Ami

First verify the version of Java being used is not Sun Java 8 SDK

java -version

Get the Sun Java 8 SDK from Oracle

wget --no-cookies --header "Cookie: gpw_e24=xxx; oraclelicense=accept-securebackup-cookie;" "http://download.oracle.com/otn-pub/java/jdk/8u73-b02/jdk-8u73-linux-x64.rpm"

Install Sun Java 8

sudo rpm -i jdk-8u73-linux-x64.rpm

Check if the default java version is set to Sun Java 8 SDK

java -version

If not then lets create one more alternative for Sun Java 8 SDK

sudo /usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.8.0_73/bin/java 20000

Set the Sun Java 8 SDK as the default java

sudo /usr/sbin/alternatives --set java /usr/java/jdk1.8.0_73/bin/java

Verify if change in SDK was done

java -version

Setup JAVA_HOME

sudo vim /etc/profile

Add inside this file the following lines

export JAVA_HOME="/usr/java/jdk1.8.0_73/"
export PATH=$JAVA_HOME/bin:$PATH

Then save it. Load the configuration immediately using

source /etc/profile

Then finally, check if it works

echo $JAVA_HOME

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment