Instantly share code, notes, and snippets.

Embed
What would you like to do?
[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

@empowerknowledge2016

This comment has been minimized.

Show comment
Hide comment
@empowerknowledge2016

empowerknowledge2016 Jan 25, 2016

Good article. installed java 8 in the ec2 isntance

empowerknowledge2016 commented Jan 25, 2016

Good article. installed java 8 in the ec2 isntance

@vanatpr

This comment has been minimized.

Show comment
Hide comment
@vanatpr

vanatpr Jan 28, 2016

Very useful. The one thing I'd add is that we need to tweak that URL to reflect the latest version of JDK (since that will evolve over time). For Chrome, I went to the JDK download page, clicked that "Accept License Agreement," and did a "Copy Link Address" on the Download link to get the URL.

vanatpr commented Jan 28, 2016

Very useful. The one thing I'd add is that we need to tweak that URL to reflect the latest version of JDK (since that will evolve over time). For Chrome, I went to the JDK download page, clicked that "Accept License Agreement," and did a "Copy Link Address" on the Download link to get the URL.

@codesurf42

This comment has been minimized.

Show comment
Hide comment
@codesurf42

codesurf42 Feb 15, 2016

Oracle doesn't make it easier... for u74:

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

codesurf42 commented Feb 15, 2016

Oracle doesn't make it easier... for u74:

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

This comment has been minimized.

Show comment
Hide comment
@ashishkp

ashishkp Feb 17, 2016

Very useful - thanks.

ashishkp commented Feb 17, 2016

Very useful - thanks.

@mohataher

This comment has been minimized.

Show comment
Hide comment
@mohataher

mohataher Mar 10, 2016

Please add how to setup JAVA_HOME too. Thanks
Maybe this step will help?

export JAVA_HOME=/usr/java/default

mohataher commented Mar 10, 2016

Please add how to setup JAVA_HOME too. Thanks
Maybe this step will help?

export JAVA_HOME=/usr/java/default
@emcenrue

This comment has been minimized.

Show comment
Hide comment
@emcenrue

emcenrue Mar 23, 2016

thanks mohataher

emcenrue commented Mar 23, 2016

thanks mohataher

@bburns

This comment has been minimized.

Show comment
Hide comment
@bburns

bburns Apr 4, 2016

This question covers upgrading to Java 8 - http://serverfault.com/questions/664643/how-can-i-upgrade-to-java-1-8-on-an-amazon-linux-server - apparently you can do

sudo yum install java-1.8.0
sudo /usr/sbin/alternatives --config java

Not sure how this differs from the other install instructions.

bburns commented Apr 4, 2016

This question covers upgrading to Java 8 - http://serverfault.com/questions/664643/how-can-i-upgrade-to-java-1-8-on-an-amazon-linux-server - apparently you can do

sudo yum install java-1.8.0
sudo /usr/sbin/alternatives --config java

Not sure how this differs from the other install instructions.

@sheshmantha

This comment has been minimized.

Show comment
Hide comment
@sheshmantha

sheshmantha Apr 11, 2016

@bburns - the serverfault url adds openjdk 1.8 NOT Oracle JDK 1.8.
Some tools, like maven, I've discovered, only work with Oracle JDK. Hence this post is VERY USEFUL

sheshmantha commented Apr 11, 2016

@bburns - the serverfault url adds openjdk 1.8 NOT Oracle JDK 1.8.
Some tools, like maven, I've discovered, only work with Oracle JDK. Hence this post is VERY USEFUL

@dspencerr

This comment has been minimized.

Show comment
Hide comment
@dspencerr

dspencerr May 7, 2016

amazing! Thanks so much for taking time to do this. I agree with @mohataher. If you can add the export JAVA_HOME command it would be perfect. I know the step, but a lot do not.

dspencerr commented May 7, 2016

amazing! Thanks so much for taking time to do this. I agree with @mohataher. If you can add the export JAVA_HOME command it would be perfect. I know the step, but a lot do not.

@rtfpessoa

This comment has been minimized.

Show comment
Hide comment
@rtfpessoa

rtfpessoa Jun 26, 2016

thanks @mohataher for the suggestion. I just updated the script and parameterized the version values to be easier to use this.

Owner

rtfpessoa commented Jun 26, 2016

thanks @mohataher for the suggestion. I just updated the script and parameterized the version values to be easier to use this.

@ph4r05

This comment has been minimized.

Show comment
Hide comment
@ph4r05

ph4r05 Aug 18, 2016

JDK 8u101

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

ph4r05 commented Aug 18, 2016

JDK 8u101

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

This comment has been minimized.

Show comment
Hide comment
@sebastientromp

sebastientromp Aug 29, 2016

After running sudo /usr/sbin/alternatives --config java the default alternative is properly set as my new java 8, but reverts back to the previous ava 7 openJDK after reboot. Any idea on how to persist the changes?

sebastientromp commented Aug 29, 2016

After running sudo /usr/sbin/alternatives --config java the default alternative is properly set as my new java 8, but reverts back to the previous ava 7 openJDK after reboot. Any idea on how to persist the changes?

@hopewise

This comment has been minimized.

Show comment
Hide comment
@hopewise

hopewise Nov 22, 2016

What's the id of the AMI used?

hopewise commented Nov 22, 2016

What's the id of the AMI used?

@snow01

This comment has been minimized.

Show comment
Hide comment
@snow01

snow01 Nov 24, 2016

JDK 8u111

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

snow01 commented Nov 24, 2016

JDK 8u111

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

This comment has been minimized.

Show comment
Hide comment
@tml

tml Jan 18, 2017

JDK 8u121-b13

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

tml commented Jan 18, 2017

JDK 8u121-b13

wget --no-cookies --header "Cookie: gpw_e24=xxx; oraclelicense=accept-securebackup-cookie;" 'http://download.oracle.com/otn-pub/java/jdk/8u121-b13/e9e7ea248e2c4826b92b3f075a80e441/jdk-8u121-linux-x64.rpm'
@artscii

This comment has been minimized.

Show comment
Hide comment
@artscii

artscii Mar 18, 2017

thanks, seems to have worked for far.

artscii commented Mar 18, 2017

thanks, seems to have worked for far.

@robmarano

This comment has been minimized.

Show comment
Hide comment
@robmarano

robmarano May 12, 2017

Seems as though the URL must include some key signature to work. The key for JDK 8u131b11 is (obviously) different from the last one poasted about. This is the URL link that worked for this version:
https://edelivery.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm

Need to figure out a way to automate this...

robmarano commented May 12, 2017

Seems as though the URL must include some key signature to work. The key for JDK 8u131b11 is (obviously) different from the last one poasted about. This is the URL link that worked for this version:
https://edelivery.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm

Need to figure out a way to automate this...

@snow01

This comment has been minimized.

Show comment
Hide comment
@snow01

snow01 Jun 25, 2017

JDK 8u131-b11

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

snow01 commented Jun 25, 2017

JDK 8u131-b11

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

@albogdano

This comment has been minimized.

Show comment
Hide comment
@albogdano

albogdano Aug 13, 2017

JDK 8u144-b01

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

albogdano commented Aug 13, 2017

JDK 8u144-b01

wget --no-cookies --header "Cookie: gpw_e24=xxx; oraclelicense=accept-securebackup-cookie;" \
"http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.rpm"
@donhenton

This comment has been minimized.

Show comment
Hide comment
@donhenton

donhenton Aug 27, 2017

I think the quotes need to come off the url? (missing schema problem)?

donhenton commented Aug 27, 2017

I think the quotes need to come off the url? (missing schema problem)?

@sumelio

This comment has been minimized.

Show comment
Hide comment
@sumelio

sumelio Oct 31, 2017

Think you, very useful

sumelio commented Oct 31, 2017

Think you, very useful

@senisas

This comment has been minimized.

Show comment
Hide comment
@senisas

senisas Nov 4, 2017

Thanks, very useful
Java SE Development Kit 8u151
wget --no-cookies --header "Cookie: gpw_e24=xxx; oraclelicense=accept-securebackup-cookie;" "http://download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/jdk-8u151-linux-x64.rpm"

senisas commented Nov 4, 2017

Thanks, very useful
Java SE Development Kit 8u151
wget --no-cookies --header "Cookie: gpw_e24=xxx; oraclelicense=accept-securebackup-cookie;" "http://download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/jdk-8u151-linux-x64.rpm"

@albogdano

This comment has been minimized.

Show comment
Hide comment
@albogdano

albogdano Nov 16, 2017

JDK 9.0.1

wget --no-cookies --header "Cookie: gpw_e24=xxx; oraclelicense=accept-securebackup-cookie;" \
"http://download.oracle.com/otn-pub/java/jdk/9.0.1+11/jdk-9.0.1_linux-x64_bin.rpm

albogdano commented Nov 16, 2017

JDK 9.0.1

wget --no-cookies --header "Cookie: gpw_e24=xxx; oraclelicense=accept-securebackup-cookie;" \
"http://download.oracle.com/otn-pub/java/jdk/9.0.1+11/jdk-9.0.1_linux-x64_bin.rpm
@m1schka

This comment has been minimized.

Show comment
Hide comment
@m1schka

m1schka Feb 8, 2018

8u151 doesn't work anymore, here is the new one for 8u162:

wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=xxx; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u162-b12/0da788060d494f5095bf8624735fa2f1/jdk-8u162-linux-x64.rpm"

m1schka commented Feb 8, 2018

8u151 doesn't work anymore, here is the new one for 8u162:

wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=xxx; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u162-b12/0da788060d494f5095bf8624735fa2f1/jdk-8u162-linux-x64.rpm"
@khoi-thinh

This comment has been minimized.

Show comment
Hide comment
@khoi-thinh

khoi-thinh Apr 24, 2018

@m1schka This doesn't work anymore.
New one for 8u172

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

khoi-thinh commented Apr 24, 2018

@m1schka This doesn't work anymore.
New one for 8u172

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

@smurty

This comment has been minimized.

Show comment
Hide comment
@smurty

smurty May 26, 2018

for 8u171 use:
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=xxx; oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.rpm

smurty commented May 26, 2018

for 8u171 use:
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=xxx; oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.rpm

@timoa

This comment has been minimized.

Show comment
Hide comment
@timoa

timoa Jul 24, 2018

for 8u181 use:

wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=xxx; oraclelicense=accept-securebackup-cookie" 
http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/jdk-8u181-linux-x64.rpm

timoa commented Jul 24, 2018

for 8u181 use:

wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=xxx; oraclelicense=accept-securebackup-cookie" 
http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/jdk-8u181-linux-x64.rpm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment