Scenario: How to install Oracle Java JDK rpm on CentOS/RHEL using command line.
Steps:
1) Go to Oracle Java download page here -> select Java rpm package then right click copy link address.
2) Putty to server then use curl command below
curl -v -j -k -L -H "Cookie: oraclelicense=accept-securebackup-cookie" #paste here the url# > /tmp/jdk-file.rpm
Example Download Java 8:
[root@centos7ht ~]# cd /tmp/
[root@centos7ht tmp]# curl -v -j -k -L -H "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/jdk-8u181-linux-x64.rpm > /opt/jdk-8u181-linux-x64.rpm
[root@centos7ht tmp]# rpm -ivh jdk-8u181-linux-x64.rpm
warning: jdk-8u181-linux-x64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:jdk1.8-2000:1.8.0_181-fcs ################################# [100%]
Unpacking JAR files...
tools.jar...
plugin.jar...
javaws.jar...
deploy.jar...
rt.jar...
jsse.jar...
charsets.jar...
localedata.jar...
[root@centos7ht tmp]# alternatives --config java
There is 1 program that provides 'java'.
Selection Command
-----------------------------------------------
*+ 1 /usr/java/jdk1.8.0_181-amd64/jre/bin/java
Enter to keep the current selection[+], or type selection number: 1
[root@centos7ht tmp]# java -version
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
[root@centos7ht tmp]#