Skip to content

Instantly share code, notes, and snippets.

@cordje
Forked from rtfpessoa/java-8-ami.md
Created October 14, 2016 13:16
Show Gist options
  • Save cordje/f9810547a773feb1121169f44ff286f9 to your computer and use it in GitHub Desktop.
Save cordje/f9810547a773feb1121169f44ff286f9 to your computer and use it in GitHub Desktop.
[Guide] Install Oracle Java (JDK) 8 on Amazon EC2 Ami

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

java -version

Check the latest version a build numbers in http://www.oracle.com/technetwork/java/javase/downloads/index.html

For url http://download.oracle.com/otn-pub/java/jdk/8u91-b14/jdk-8u91-linux-x64.tar.gz, the variables should be defined as:

java_base_version="8"
java_sub_version="11"
java_base_build="14"

java_version="${java_base_version}u${java_sub_version}"
java_build="b${java_base_build}"
java_version_with_build="${java_version}-${java_build}"

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/${java_version_with_build}/jdk-${java_version}-linux-x64.rpm"

Install Sun Java 8

sudo rpm -i jdk-${java_version}-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.${java_base_version}.0_${java_sub_version}/bin/java 20000

Set the Sun Java 8 SDK as the default java

sudo /usr/sbin/alternatives --config java

Verify if change in SDK was done

java -version

Add the export of the java home to your .bashrc, .bash_profile, .zshrc, or any other relevant file.

export JAVA_HOME=/usr/java/default

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