1. Search for and delete older versions of the JDK or openjdk under the CENTOS7 system, search instructions: RPM-QA | grep java
The removal instructions are:rpm-e--nodeps, such as: Rpm-e--nodeps java-1.7.0-openjdk-headless-1.7.0.71-2.5.3.1.el7_0.x86_64.
2. After removing the clean, right-click on the terminal under the folder of the Jdk-8u45-linux-x64.tar.gz installation package , then unzip the installation package to the specified folder.
The decompression instruction is:tar-zxvf jdk-8u45-linux-x64.tar.gz-c/usr/local
Here I unzipped the installation package under/usr/local 。注意-C,后面要添加路径 .
3. Set environment variables, the first is to open the folder setting environment variables, the instruction is:vim/etc/profile and then in the English input method to switch to the "insert" state , you can directly at the beginning of the "# will prevent the need For merging in the future updates. The following environment variables are configured under this line:
Export JAVA_HOME=/USR/LOCAL/JDK1.8.0_45 export JRE_HOME=/USR/LOCAL/JDK1.8.0_45/JRE export classpath=.: $JAVA _home/ Lib/dt.jar: $JAVA _home/lib/tools.jar: $JRE _home/lib: $CLASSPATH export path= $JAVA _home/bin: $PATH
Press ":: Wq" to save after exiting, enter directive:source/etc/profile The environment variable that is set to take effect.
4. Check if the installation is successful, enter the command:java-version , if the terminal appears
Java version "1.8.0_45" Java (tm) SE Runtime Environment (build 1.8.0_45-b14) Java HotSpot (tm) 64-bit Server VM (Build 25.4 5-B02, Mixed mode)
Indicates that the installation was successful.
Linux Configuration JDK Environment variables