1. Check the installed JDK
grep Java
The possible results are as follows:
java-1.7.0-openjdk-1.7.0.99-2.6.5.0. El7_2.x86_64python-javapackages-3.4.1- One. El7.noarchjava-1.8.0-openjdk-headless-1.8.0.77-0. B03.el7_2.x86_64java-1.8.0-openjdk-1.8.0.77-0. B03.el7_2.x86_64tzdata-java-2016c-1. El7.noarchjavapackages-tools-3.4.1- One. El7.noarchjava-1.7.0-openjdk-headless-1.7.0.99-2.6.5.0. el7_2.x86_64
2. Removal of installed OPEN-JDK and dependent programs
Yum Remove tzdata-java-2016c-1. El7.noarch
All OPEN-JDK and other software that is dependent on OPEN-JDK will be removed at this time.
3. To Oracle download JDK8, as I downloaded is jdk-8u65-linux-x64.rpm
Execute the installation command in the corresponding directory:
RPM-IVH jdk-8u65-linux-x64.rpm
Program is installed by default to/usr/java/jdk1.8.0_65
Check the installation status:
[Email protected] jdk]# java-"1.8.0_65"1.8. 0_65- - 25.65--1.80_65
Check the file path:
[Email protected] jdk]#WhereisJavajava:/usr/bin/java/usr/lib/java/etc/java/usr/share/java/usr/share/Mans/man1/java.1[email protected] jdk]# ll/usr/bin/javalrwxrwxrwx1Root root AMar - One: the/usr/bin/java-/etc/alternatives/Java[[email protected] jdk]# ll/etc/alternatives/javalrwxrwxrwx1Root root theMar - One: the/etc/alternatives/java,/usr/java/jdk1.8.0_65/jre/bin/java
To add an environment variable file:
VI /etc/profile.d/jdk8. SH
Add the following content
Java_home=/usr/java/jdk1. 8 . 0_65jre_home=/usr/java/jdk1. 8. 0_65/Jreclasspath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar: $JRE _home/Libexport Java_home jre_home CLASSPATH
Make the changes effective
Source/etc/profile
Check if it takes effect
env| grep javajre_home=/usr/java/jdk1. 8. 0_65/jrejava_home=/usr/java/jdk1. 8 . 0_65classpath=.:/ Usr/java/jdk1. 8. 0_65/lib/dt.jar:/usr/java/jdk1. 8. 0_65/lib/tools.jar:/usr/java/jdk1. 8. 0_65/jre/lib
OK, here we go.
Installing and configuring JDK8 in CentOS 7