Install JDK1.8 on CentOS7

1 Connect to Alibaba Cloud CentOS7 server through SecureCRT;

2 Go to the directory /usr/local/:
 cd /usr/local/

3 Create a directory tools:
 mkdir -p tools

4 Go to the directory /usr/local/tools:
 cd tools/

5 下载 jdk-8u91-linux-x64.tar.gz:
 wget --no-check-certificate --no-cookies --header "Cookie: Oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/7u71-b14/jdk-7u71-linux-x64.rpm
 wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u91-b14/jdk-8u91-linux-x64.tar.gz
 wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u91-b14/jdk-8u91-linux-x64.rpm
 wget --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie;" http://download.oracle.com/otn-pub/java/jdk/7u65-b17/jdk-7u65-linux-x64.tar
 wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.2.6.tgz
 wget http://download.redis.io/releases/redis-3.0.7.tar.gz
 wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-9/v9.0.0.M4/bin/apache-tomcat-9.0.0.M4.tar.gz
 wget http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.12-1.el7.x86_64.rpm-bundle.tar
 wget http://apache.fayea.com/zookeeper/zookeeper-3.4.8/zookeeper-3.4.8.tar.gz
 wget http://memcached.org/files/memcached-1.4.25.tar.gz

6 Compress the jdk-8u91-linux-x64.tar.gz file:
 tar -zxvf jdk-8u91-linux-x64.tar.gz

7 Go back one level and create the /usr/local/jdk directory:
 cd ..
 mkdir -p jdk

8 After entering the tools directory, move jdk1.8.0_91 to the jdk directory:
 cd ../tools/
 mv jdk1.8.0_91/ ../jdk/

9 Open the profile file in the /etc/ directory:
 vi /etc/profile
 Append the following code to the end of the profile file:
 # idea - jdk8 settings start 2016-05-01

JAVA_HOME=/usr/local/jdk/jdk1.8.0_91
 JRE_HOME=$JAVA_HOME/jre
 PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
 CLASSPATH=:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib/dt.jar
 export JAVA_HOME JRE_HOME PATH CLASSPATH

# idea - jdk8 settings end - 2016-05-01
 Press the Esc key, enter wq! Enter, hold and exit.

10 to enable the new profile:
 source /etc/profile

11 输入 java -version 查看 JDK 的版本:
 [root@iZ94hws2fzlZ jdk1.8.0_91]# java -version
 java version "1.8.0_91"
 Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
 Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)

Guess you like

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