1. Open the url to download jdk1.8
click to download
2.Installation
2.1 Create directory
mkdir /usr/local/java/
2.2 Unzip to the installation directory
tar -zxvf jdk-8u171-linux-x64.tar.gz -C /usr/local/java/
3. Environment variable configuration
3.1 Open the file
vim /etc/profile
3.2 Add at the end
export JAVA_HOME=/usr/local/java/jdk1.8.0_171
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
3.3 Make environment variables effective
source /etc/profile
3.4 Add soft connection
ln -s /usr/local/java/jdk1.8.0_171/bin/java /usr/bin/java
4. Check whether the installation is successful
java -version