CentOS7 安装 oracle jdk8

2016-12-02  本文已影响0人  M醉逍遥

1.下载orcale jdk:

下载地址:http://www.oracle.com/technetwork/java/javase/downloads/index.html

2.卸载系统自带jdk:

[root@localhost ~]# rpm -qa | grep java
python-javapackages-3.4.1-11.el7.noarch
javapackages-tools-3.4.1-11.el7.noarch
java-1.8.0-openjdk-1.8.0.65-3.b17.el7.x86_64
java-1.7.0-openjdk-1.7.0.91-2.6.2.3.el7.x86_64
java-1.8.0-openjdk-headless-1.8.0.65-3.b17.el7.x86_64
java-1.7.0-openjdk-headless-1.7.0.91-2.6.2.3.el7.x86_64
[root@localhost ~]# rpm -e --nodeps java-1.8.0-openjdk-1.8.0.65-3.b17.el7.x86_64
[root@localhost ~]# rpm -e --nodeps java-1.7.0-openjdk-1.7.0.91-2.6.2.3.el7.x86_64
[root@localhost ~]# rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.65-3.b17.el7.x86_64
[root@localhost ~]# rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.91-2.6.2.3.el7.x86_64

3.安装orcale jdk8:

解压文件(若文件下载到的是home目录)

[root@localhost ~]# tar -zvxf jdk-8u111-linux-x64.tar.gz

在/usr/local/目录下创建java目录:

[root@localhost ~]# mkdir /usr/local/java

拷贝文件到/usr/local/java目录:

[root@localhost ~]# cp ~/jdk1.8.0_111 /usr/local/java/

配置环境变量,打开/etc/profile文件,在文件末尾添加如下内容:

#Java
export JAVA_HOME=/usr/local/java/jdk1.8.0_111
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin

让环境变量生效:

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

使用如下命令检查是否安装成功:

[root@localhost ~]# 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)
上一篇下一篇

猜你喜欢

热点阅读