Install jdk1.8 on CentOS7
1. Create a Java folder under the/var/local directory.
mkdir /var/local/java
Copy jdk to/var/local/java to enter the java folder and decompress the compressed package.
tar xvf jdk-8u112-linux-x64.gz
2. Set the environment variable. The global setting method is used here to modify the etc/profile. It is the environment variable shared by all users. Locate/etc/profile, edit it, and add it at the end.
export JAVA_HOME=/var/local/java/jdk1.8.0_112export JRE_HOME=/var/local/java/jdk1.8.0_112/jreexport CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:$CLASSPATHexport PATH=$JAVA_HOME/bin:$PATH
Remember, do not add spaces on both sides of the equal sign during the above process. Otherwise, "invalid identifiers" will appear, because unnecessary spaces cannot be identified during source/etc/profile, it is understood as part of the path. Then save
Run the following command to make the profile take effect
source /etc/profile
3. Check whether the operation is successful on the terminal
java -version
javac