Install Latest Oracle JDK On Linux EC2 Instance

We will explore the procedure to install latest java 8 version ie JDK 8u121 on the EC2 Linux instance which comes with centOS as its default operating system. Following steps must be followed sequentially :

Step 1 -> Ssh to your instance

Login with your pem file or ssh user@IP

Step 2 -> Check the Java version

java -version

As can be seen in the above, is java is installed or not on the EC2 instance by default. If not installed then follow the next step:

Step 3 -> Download RPM package of Oracle JDK (8u121)

wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.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.

Step 4 -> Install JDK 8

sudo yum install -y jdk-8u141-linux-x64.rpm

Step 5 -> Verify oracle JDK version

java -version

The java version is now updated. You may now delete jdk-8u121-linux-x64.rpm file.

For any questions or suggestions, please leave comments.

Thank you

Happy Coding

Written by

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store