1, uninstall the system's own OPENJDK and related Java files
(1) Check the OPENJDK version information that comes with the system, and in the command window, type: java-version
(2) Rpm-qa | grep java
RPM Management Suite
-qa use Inquiry mode to query all packages
In the above file:
The following few can be removed
Java-1.7.0-openjdk-1.7.0.151-2.6.11.1.el7_4.x86_64
Java-1.8.0-openjdk-headless-1.8.0.151-1.b12.el7_4.x86_64
Java-1.8.0-openjdk-1.8.0.151-1.b12.el7_4.x86_64
Java-1.7.0-openjdk-headless-1.7.0.151-2.6.11.1.el7_4.x86_64
Noarch files can not be deleted
Python-javapackages-3.4.1-11.el7.noarch
Tzdata-java-2017c-1.el7.noarch
Javapackages-tools-3.4.1-11.el7.noarch
(3) Complete the delete file command in the Command window type (note the need to switch to the root user, otherwise it will delete the failure):
RPM-E--nodeps java-1.7.0-openjdk-1.7.0.151-2.6.11.1.el7_4.x86_64
RPM-E--nodeps java-1.8.0-openjdk-headless-1.8.0.151-1.b12.el7_4.x86_64
RPM-E--nodeps java-1.8.0-openjdk-1.8.0.151-1.b12.el7_4.x86_64
RPM-E--nodeps java-1.7.0-openjdk-headless-1.7.0.151-2.6.11.1.el7_4.x86_64
Command Description:
RPM Management Suite
-e Delete the specified package
--nodeps does not verify the correlation of the suite files
(4) Check whether it has been deleted successfully
In the Command window, type: java-version
The delegate has been deleted successfully.
2. Download JDK
(1) Historical version: Http://www.oracle.com/technetwork/java/javase/archive-139210.html
I was in the Centos7 browser to download the JDK:
Download by browser will be downloaded by default to the current user's download directory,
For example, the current login user is root, then the download location is "/root/Download/jdk-8u144-linux-x64.tar.gz":
Download Complete:
(2) You can see the specific path of the downloaded package:
Find/-name ". tar.gz"
(3) Back up the file to software and copy it to/usr/java:
(4) Unzip the JDK under/usr/java
TAR-ZXVF jdk-8u144-linux-x64.tar.gz
(5) Remove JDK
RM-RF jdk-8u144-linux-x64.tar.gz
4. Configuring the JDK environment variables
(1) Editing global variables
Vi/etc/profile
Enter Insert State:
Paste the following on the last line of the text:
Note that java_home=/usr/java/jdk1.8.0_144 is your own directory.
"Note": CentOS6 above is javahome,centos7 {java_home}
(2) Allow the environment variable you just set to take effect and check if the installation was successful
Immediate effect: Source/etc/profile
View Java version: Java-version
Centos7 Installing the JDK