1 vi / etc / profile configuration environment variable
Copy to reciprocal done
export JAVA_HOME=/root/jdk1.8/jdk1.8.0_221
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH
export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin
export PATH=$PATH:${JAVA_PATH}
Note: If the extraction path behind JAVA_HOME own jdk Oh!
2 source / etc / profile for the configuration file to take effect.
3 java -version