cents

 

 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

  1. [root@localhost ~]# mkdir/usr/java  
  2. [root@localhost ~]# cd /usr/java  
  3. [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 

  1. [root@localhost ~]# rpm -qa | grep java  
  2. tzdata-java-2012c-1.el6.noarch  
  3. java-1.7.0-openjdk-1.7.0.45-1.45.1.11.1.el6.x86_64  

 

  To uninstall OpenJDK, do the following:

 

  1. [root@localhost ~]# rpm -e --nodeps tzdata-java-2012c-1.el6.noarch  
  2. [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

  1. [root@localhost java]# vi /etc/profile  

 

  1. JAVA_HOME=/usr/java/jdk1.8.0_121  
  2. JRE_HOME=/usr/java/jdk1.8.0_121/jre  
  3. CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib  
  4. PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin  
  5. export JAVA_HOME JRE_HOME CLASS_PATH PATH  

 

 To make the changes take effect:

[root@localhost java]# source /etc/profile

 

4. Verify JDK validity

  1. java -version  
  2. java version "1.8.0_121"  
  3. java(TM) SE Runtime Environment(build 1.8.0_121-b13)  
  4. java HotSpot(TM) 64-Bit Server VM(build 25.121-b13,mixed mode)  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326219366&siteId=291194637