Installing Oracle JRE using command line (no repo)

There is no way to easily automate deployment of Oracle JRE since there is no official repository for most of the linux distros. But there’s still a workaround to automatically download the JRE and install it locally on a server by using command lines.

Here is an example of how you can download the JRE 1.8u172 from official website for a CentOS server. You’ll have to grab the URL of the package you want to download from the website http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html

First, download the package from the website by accepting the license automatically:

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

Then, install the package you downloaded on the server:

sudo yum localinstall jre-8u172-linux-x64.rpm