Because Centos is used, install JDK, first download it from the official website
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Download an rpm package here, and after downloading, get a link with a key
1.0
wget http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm?AuthParam=1498094666_ea28c4a293ab2f7f56f0f03f3f79cf6a
Download it into the /usr/java/ directory
- [root@localhost ~]# mkdir/usr/java
- [root@localhost ~]# cd /usr/java
- [root@localhost java]# tar -zxvf jdk-8u121-linux-x64.tar.gz
2.0 Before installation, you need to uninstall the jdk that comes with linux.
First find the installed jdk
- [root@localhost ~]# rpm -qa | grep java
- tzdata-java-2012c-1.el6.noarch
- java-1.7.0-openjdk-1.7.0.45-1.45.1.11.1.el6.x86_64
To uninstall OpenJDK, do the following:
- [root@localhost ~]# rpm -e --nodeps tzdata-java-2012c-1.el6.noarch
- [root@localhost ~]# rpm -e --nodeps java-1.8.0-openjdk-1.8.0.45-1.45.1.11.1.el6.x86_64
-e : uninstall
--nodeps: ignore dependencies
Installer
#rpm -ivh jdk1.8.0_121
Oh, by the way, you also need to set permissions for jdk,
After installation, you need to add executable permissions to all users
#chmod 777 jdk1.8.0_121
// Because I am testing here, I will give the permission to 777 to fully open the permission
After installation, you need to configure the path! It is the same as configuring JAVA_HOME with the window environment variable. Without further ado, start configuring
- [root@localhost java]# vi /etc/profile
- JAVA_HOME=/usr/java/jdk1.8.0_121
- JRE_HOME=/usr/java/jdk1.8.0_121/jre
- CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
- PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
- export JAVA_HOME JRE_HOME CLASS_PATH PATH
To make the changes take effect:
[root@localhost java]# source /etc/profile
4. Verify JDK validity
- java -version
- java version "1.8.0_121"
- java(TM) SE Runtime Environment(build 1.8.0_121-b13)
- java HotSpot(TM) 64-Bit Server VM(build 25.121-b13,mixed mode)