centos6.8安裝jdk8

孤竹星發表於2016-12-23
環境:
系統:centos6.8
JDK:1.8  ,rpm tar.gz

jdk8 下載位置


安裝方法
方法一:手動解壓JDK的壓縮包,設定環境變數
方法二:yum安裝JDK
方法三:用rpm安裝JDK

方法一:手動解壓JDK的壓縮包,設定環境變數
1.建立java目錄
[root@centos6-01 ~]# mkdir /usr/java
[root@centos6-01 ~]# cd /usr/java/

2.下載,然後解壓,這一步我已經將軟體下載並放到/sofwaretar  目錄下
複製到/usr/java
[root@centos6-01 java]# cp /softwaretar/jdk-8u111-linux-x64.tar.gz ./
[root@centos6-01 java]# ll
total 177192
-rw-r--r--. 1 root root 181442359 Dec 23 14:04 jdk-8u111-linux-x64.tar.gz
[root@centos6-01 java]# tar -zxvf jdk-8u111-linux-x64.tar.gz 
3.設定環境變數
[root@centos6-01 java]# vi /etc/profile

新增如下內容:
#set java environment
JAVA_HOME=/usr/java/jdk1.8.0_111
JRE_HOME=/usr/java/jdk1.8.0_111/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

生效修改
[root@centos6-01 java]#source /etc/profile

4.驗證
[root@centos6-01 java]# java -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

方法二:yum安裝JDK

1.檢視yum庫中有那些jdk版本
[root@centos6-01 java]# yum search java|grep jdk
ldapjdk-javadoc.x86_64 : Javadoc for ldapjdk
java-1.6.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.6.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.6.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.6.0-openjdk-javadoc.x86_64 : OpenJDK API Documentation
java-1.6.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.7.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.7.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.7.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.7.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.8.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.8.0-openjdk-debug.x86_64 : OpenJDK Runtime Environment with full debug on
java-1.8.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.8.0-openjdk-demo-debug.x86_64 : OpenJDK Demos with full debug on
java-1.8.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.8.0-openjdk-devel-debug.x86_64 : OpenJDK Development Environment with
java-1.8.0-openjdk-headless.x86_64 : OpenJDK Runtime Environment
java-1.8.0-openjdk-headless-debug.x86_64 : OpenJDK Runtime Environment with full
java-1.8.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.8.0-openjdk-javadoc-debug.noarch : OpenJDK API Documentation for packages
java-1.8.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.8.0-openjdk-src-debug.x86_64 : OpenJDK Source Bundle for packages with
ldapjdk.x86_64 : The Mozilla LDAP Java SDK

2.選擇版本,進行安裝
[root@centos6-01 java]# yum install java-1.8.0-openjdk

3.設定環境變數
[root@centos6-01 java]# vi /etc/profile

新增如下內容:
#set java environment
JAVA_HOME= /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.111-0.b15.el6_8.x86_64/
JRE_HOME= /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.111-0.b15.el6_8.x86_64//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

生效修改
[root@centos6-01 java]#source /etc/profile

4.驗證
[root@centos6-01 java]# java -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

方法三:用rpm安裝JDK

1. 下載
已下載軟體到/usr/java   目錄下

2.使用rpm命令安裝
rpm -ivh jdk-8u111-linux-x64.rpm 

3.設定環境變數
[root@centos6-01 java]# vi /etc/profile

新增如下內容:
#set java environment
JAVA_HOME=/usr/java/jdk1.8.0_111
JRE_HOME=/usr/java/jdk1.8.0_111/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

生效修改
[root@centos6-01 java]#source /etc/profile

4.驗證
[root@centos6-01 java]# java -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28282660/viewspace-2131288/,如需轉載,請註明出處,否則將追究法律責任。

相關文章