Installing jdk under Linux is not the same as windows, it is a little more complicated, and record the installation process again
1. First, uninstall the built-in openJDK and files
1.1 Type in the terminal:
java -version
You can see the OpenJDK version information that comes with the system.
1.2 Type in the command window
rpm -qa | grep java
rpm | Management suite |
-qa | Use query mode to query all packages |
grep | Find the qualified string in the file |
java | Find files containing java strings |
These few of the above files can be deleted
java-1.8.0-openjdk-1.8.0.102-4.b14.el7.x86_64
java-1.8.0-openjdk-headless-1.8.0.102-4.b14.el7.x86_64
java-1.7.0-openjdk-headless-1.7.0.111-2.6.7.8.el7.x86_64
java-1.7.0-openjdk-1.7.0.111-2.6.7.8.el7.x86_64
noarch file can be deleted
javapackages-tools-3.4.1-11.el7.noarch
tzdata-java-2016g-2.el7.noarch
python-javapackages-3.4.1-11.el7.noarch
1.3 Type in the command window (permissions may not be enough, we can switch root, su root)
rpm -e --nodeps java-1.7.0-openjdk-1.7.0.111-2.6.7.8.el7.x86_64
For the complete delete file command, type in the command window:
rpm -e --nodeps java-1.7.0-openjdk-1.7.0.111-2.6.7.8.el7.x86_64
rpm -e --nodeps java-1.8.0-openjdk-1.8.0.102-4.b14.el7.x86_64
rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.102-4.b14.el7.x86_64
rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.111-2.6.7.8.el7.x86_64
The second step is to download the latest stable JDK
Official website: https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html
Transfer the downloaded compressed package to Linux through xftp software
I transferred it to the /opt file of Linux
Unzip the compressed package of /opt
tar -xvzf jdk-8u121-linux-x64.tar.gz
Enter the compressed file: save this /opt/jdk1.8_121
cd jdk1.8.0_121/
Edit in it, add some content
Save and exit: wq
Check if the installation is successful