首頁 > 軟體

在CentOS7上安裝JDK1.8

2020-06-16 17:38:48

CentOS7上安裝JDK1.8

1 通過 SecureCRT 連線到阿里雲 CentOS7 伺服器;

2 進入到目錄 /usr/local/ 中:
 cd /usr/local/

3 建立目錄 tools:
 mkdir -p tools

4 進入到目錄 /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 加壓縮 jdk-8u91-linux-x64.tar.gz 檔案:
 tar -zxvf jdk-8u91-linux-x64.tar.gz

7 返回到上一級並建立 /usr/local/jdk 目錄:
 cd ..
 mkdir -p jdk

8 進入到 tools 目錄後將 jdk1.8.0_91 移動到 jdk 目錄中:
 cd ../tools/
 mv jdk1.8.0_91/ ../jdk/

9 開啟 /etc/ 目錄下的 profile 檔案:
 vi /etc/profile
 將如下程式碼追加到 profile 檔案末尾:
 # 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
 按 Esc 鍵、輸入 wq! 回車,保持並退出。

10 即可啟用新的設定:
 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)

Ubuntu 14.04安裝JDK1.8.0_25與設定環境變數 http://www.linuxidc.com/Linux/2015-01/112030.htm 

CentOS 搭建JDK環境  http://www.linuxidc.com/Linux/2015-06/118879.htm 

Ubuntu 14.04安裝JDK1.8.0_25與設定環境變數  http://www.linuxidc.com/Linux/2015-01/112030.htm 

Ubuntu 14.04 LTS安裝Oracle JDK 1.8  http://www.linuxidc.com/Linux/2014-11/109216.htm 

CentOS6.3安裝JDK和環境設定 http://www.linuxidc.com/Linux/2012-09/70780.htm 

Ubuntu 14.04 安裝 JDK8  http://www.linuxidc.com/Linux/2014-09/106218.htm 

Ubuntu下安裝JDK圖文解析 http://www.linuxidc.com/Linux/2014-09/107291.htm 

本文永久更新連結地址http://www.linuxidc.com/Linux/2016-06/132678.htm


IT145.com E-mail:sddin#qq.com