One uninstall:
(1) View Java version:
[[email protected] src]# java-versionopenjdk version "1.8.0_91" OpenJDK Runtime Environment (build 1.8.0_91-b14) OpenJDK 6 4-bit Server VM (build 25.91-b14, Mixed mode)
(2) Query all Java-related installation RPM packages:
[Email protected] src]# Rpm-qa | Grep Javatzdata-java-2016d-1.el7.noarchjavapackages-tools-3.4.1-11.el7.noarchjava-1.7.0-openjdk-headless-1.7.0.101-2.6.6.1.el7 _2.x86_64java-1.7.0-openjdk-1.7.0.101-2.6.6.1.el7_2.x86_64java-1.8.0-openjdk-1.8.0.91-0.b14.el7_2.x86_ 64python-javapackages-3.4.1-11.el7.noarchjava-1.8.0-openjdk-headless-1.8.0.91-0.b14.el7_2.x86_64
(3) Uninstall all packages related to OPENJDK:
[Email protected] src]# rpm-e--nodeps java-1.7.0-openjdk-1.7.0.101-2.6.6.1.el7_2.x86_64[[email protected] src]# RPM- E--nodeps java-1.8.0-openjdk-1.8.0.91-0.b14.el7_2.x86_64[[email protected] src]# rpm-e--nodeps Java-1.8.0-openjdk-headless-1.8.0.91-0.b14.el7_2.x86_64
(4) Check the JDK version again when the uninstallation is complete:
[Email protected] src]# Java-version-bash:/usr/bin/java:no such file or directory
You can see that it is now showing the status of not installed. At this point, openjdk all uninstall complete
Two installing the Sun JDK
(1) Download the RPM package for the JDK and install it:
[[email protected] src]# lsapache-tomcat-h5.zip nginx-1.4.7.tar.gz Pcre-8.36.tar.gzjdk-7u71-linux-x64.rpm nginx_upstream_ Hash-0.3.1.tar.gzkeepalived-1.2.2.tar.gz ngx_cache_purge-2.0.tar.gz[[email protected] src ]# rpm -ivh jdk-7u71-linux-x64.rpmpreparing... ## ############################### [100%]updating / installing... 1:jdk-2000 : 1.7.0_71-fcs ######################### ######## [100%]unpacking jar files... rt.jar ... jsse.jar... charsets.jar... tools.jar ... localedata.jar... jfxrt.jar ...
Note: Because I have already downloaded it in advance, I have installed it directly here.
(2) Configure the environment variables for the JDK:
[Email protected] src]# Vim/etc/profile
Enter this file to find the EXPORT PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC
Export java_home= "/usr/java/jdk1.7.0_71" Export classpath= ".:/ Usr/java/jdk1.7.0_71/lib:/usr/java/jdk1.7.0_71/jre/lib "pathmunge/usr/java/jdk1.7.0_71/bin:/usr/java/jdk1.7.0_ 71/jre/bin
Note: The path to the Java involved above is set according to your own Java path. Of course, you can use this command to find:
[email protected] src]# which Java
After editing is complete, press ESC to return to command mode, and then save to exit
(3) Update the configuration without restarting the server:
[Email protected] src]# Source/etc/profile
(4) The final effect is as follows:
[[email protected] src]# Java-versionjava version "1.7.0_71" Java (TM) SE Runtime Environment (build 1.7.0_71-b14) Java Hots Pot (TM) 64-bit Server VM (build 24.71-b01, Mixed mode)
Here, all configurations complete
This article is from "Zifangsky's personal blog" blog, make sure to keep this source http://983836259.blog.51cto.com/7311475/1773600
Detailed steps to uninstall OPENJDK and install Sun JDK under Linux