How to install latest JDK on EC2 node (Amazon Linux)
05 May 2018
- By default there is OpenJDK-7:
[ec2-user@ip-1-2-3-4 ~]$ java -version java version "1.7.0_171" OpenJDK Runtime Environment (amzn-2.6.13.0.76.amzn1-x86_64 u171-b01) OpenJDK 64-Bit Server VM (build 24.171-b01, mixed mode)
- Download the java distrobutive (get a link from oracle site -> http://www.oracle.com/technetwork/java/javase/downloads/jdk10-downloads-4416644.html)
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/10.0.1+10/fb4372174a714e6b8c52526dc134031e/jdk-10.0.1_linux-x64_bin.rpm
NOTE: It is important to manually instruct wget to send the cookie and here this is done using
–-header “Cookie: oraclelicense=accept-securebackup-cookie”
where oraclelicense is the name of the cookie and accept-securebackup-cookie is its value.
- Install the downladed distribution:
sudo yum install -y jdk-10.0.1_linux-x64_bin.rpm
- Check the java version:
[ec2-user@ip-1-2-3-4 ~]$ java -version java version "10.0.1" 2018-04-17 Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10) Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)
- If you need to create $JAVA_HOME variable for all users ```bash
vi /etc/bashrc
export JAVA_HOME=/usr/java/jdk1.8.0_171-amd64
```