Uninstall the built-in JDK
rpm -qa | grep jdk
First check which JDK versions are available
[root @ eno1 etc] # RPM - qa | grep JDK Java - 1.7.0 - its - 1.7.0.91-2.6.2.1.0.1. El7_1. X86_64 Java - 1.7.0 - its - headless - 1.7.0.91-2.6.2.1.0.1. El7_1. X86_64Copy the code
Yum - y remove Java - 1.7.0 - its - 1.7.0.91-2.6.2.1.0.1. El7_1. X86_64
Yum - y remove Java - 1.7.0 - its headless - 1.7.0.91-2.6.2.1.0.1. El7_1. X86_64
Uninstall them one by one
Install JDK1.8
Download the JDK1.8 package openjdk-8u41-b04-linux-x64-14_jan_2020.tar.gz
Decompress the tar package
tar -zxvf openjdk-8u41-b04-linux-x64-14_jan_2020.tar.gz
Vi /etc/profile, add to the end
Export JAVA_HOME = / usr/lib/Java - 1.8.0 comes with/Java se - 8 u41 - ri export CLASSPATH =. : $JAVA_HOME/lib/dt. The jar: $JAVA_HOME/lib/tools. The jar export PATH=$PATH:$JAVA_HOME/binCopy the code
Then let the environment variables take effect
source /etc/profile
Java -version The version number is 1.8