First step: Install the JDK, first check whether the JDK is present, enter the following command:
Java-version
Not installed will display:
[Email protected]/]# java-/]#
Second step: Download the corresponding JDK on the official website, download the jdk-7u79-linux-x64.tar.gz, create a new Java folder in the/usr directory
Mkdir/usr/java
Step three: Place the downloaded JDK under the created Java folder for decompression
TAR–ZXVF jdk-7u79-linux-x64.tar.gz
Fourth step: Set the JDK environment variables, modify the Etc/profile
Vi/etc/profile
Add the following code at the end:
export PATH USER LOGNAME MAIL HOSTNAME histsize histcontrolexport java_home=/usr/java/jdk1.7. 0_79export PATH= $JAVA _home/bin: $PATHexport CLASSPATH=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
Note: Do not include a space on either side of the equal sign, or "not a valid identifier" will appear
Fifth step: Make profile effective
Source/etc/profile
Sixth step: Test success
Java-version
The following results have been successfully installed:
[Email protected]/]# java-"1.7.0_79"1.7.0_79-64-bit Server VM (build 24.79-b02, Mixed mode )
Centos 7 JDK installation (not previously installed by default)