Download the rpm package jdk-8u171-linux-x64.rpm
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Install
rpm -ivh jdk-8u45-linux-x64.rpm
After the installation, jdk will be installed under /usr/java/, and then configure the environment variables.
vi /etc/profile
Enter i to edit the text
Then add at the end of the file content
export JAVA_HOME=/usr/java/jdk1.8.0_45
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=$JAVA_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
Then press the esc key, enter: wq to save and exit (PS: the input is colon+w+q)
Make the file take effect immediately
source /etc/profile
Finally java -version to see if the installation is successful