First step: See which packages are installed
[Email protected] ~]# Rpm-qa | grep java
Tzdata-java-2016g-2.el7.noarch
Python-javapackages-3.4.1-11.el7.noarch
Java-1.7.0-openjdk-headless-1.7.0.111-2.6.7.8.el7.x86_64
Java-1.8.0-openjdk-headless-1.8.0.102-4.b14.el7.x86_64
Java-1.8.0-openjdk-1.8.0.102-4.b14.el7.x86_64
Java-1.7.0-openjdk-1.7.0.111-2.6.7.8.el7.x86_64
Javapackages-tools-3.4.1-11.el7.noarch
Step Two: Uninstall
Execute the following command separately
[email protected] ~]# Yum Remove *openjdk*
。。。 #打印日志信息
Do you want to continue? [Y/n]:y #中途提示是否继续, enter Y, press the ENTER key to
。。。
[Email protected] ~]# Yum-remove Tzdata-java-2016g-2.el7.noarch
。。。 #打印日志信息
Do you want to continue? [Y/n]:y #中途提示是否继续, enter Y, press the ENTER key to
。。。
[email protected] ~]# Yum Remove Python-javapackages-3.4.1-11.el7.noarch
。。。 #打印日志信息
Do you want to continue? [Y/n]:y #中途提示是否继续, enter Y, press the ENTER key to
。。。
[Email protected] ~]# Rpm-qa | grep Java #最后查看, found all uninstall with Java completed (if you have not uninstalled, continue to execute the Yum remove command)
[Email protected] ~]#
Step three: Install the JDK
Here, take tar.gz as an example.
[[email protected] installfile]# tar-zxvf jdk-8u171-linux-x64.tar.gz-c/java #把安装包解压到/java Directory
Fourth Step: Configure environment variables
[Email protected] ~]# Vim/etc/profile
Export java_home=/java/jdk1.8.0_171/#这里写自己的java安装目录, this is/java/jdk1.8.0_171/.
Export path= $PATH: $JAVA _home/bin
Export Classpath=.:java_home/jre/lib/rt.jar: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
Fifth step: Environment variables take effect
[Email protected] ~]# Source/etc/profile
Sixth step: see if the installation is successful
[Email protected] ~]# java-version
Java Version "1.8.0_171"
Java (TM) SE Runtime Environment (build 1.8.0_171-B11)
Java HotSpot (TM) 64-bit Server VM (build 25.171-b11, Mixed mode)
The above version information appears, indicating that the JDK installation was successful!
Linux delete your own openjdk, install jdk1.8