目录
[TOC]
1. 版本说明
Linux系统版本:
7.3
.1611JDK版本:
1.8
.0_121
2. 卸载系统自带JDK
(1)查看系统当前安装的JDK
rpm -qa | grep java
查询结果如下(高亮部分为系统自带jdk,需要删除):
java-1.8.0-openjdk-1.8.0.102-4.b14.el7.x86_64
javapackages-tools-3.4.1-11.el7.noarch
java-1.8.0-openjdk-headless-1.8.0.102-4.b14.el7.x86_64
tzdata-java-2016g-2.el7.noarch
python-javapackages-3.4.1-11.el7.noarch
java-1.7.0-openjdk-headless-1.7.0.111-2.6.7.8.el7.x86_64
java-1.7.0-openjdk-1.7.0.111-2.6.7.8.el7.x86_64
(2)删除系统自带JDK
rpm -e --nodeps java-1.8.0-openjdk-1.8.0.102-4.b14.el7.x86_64
rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.102-4.b14.el7.x86_64
rpm -e --nodeps java-1.7.0-openjdk-1.7.0.111-2.6.7.8.el7.x86_64
rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.111-2.6.7.8.el7.x86_64
3. 下载JDK
下载地址:
下载文件:jdk-8u121-linux-x64.tar.gz
下载到目录:/home/hadoop/install
4. 安装JDK
(1)解压JDK到指定目录/usr/local/dsj(如没有此目录,需创建):
cd /home/hadoop/install
tar -zxvf jdk-8u121-linux-x64.tar.gz -C /usr/local/dsj
解压后目录:/usr/local/dsj/jdk1.8.0_121
(2)配置环境变量
打开配置文件
vi /etc/profile
(3)配置文件最下方增加配置
export JAVA_HOME=/usr/local/dsj/jdk1.8.0_121
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
(4)启用最新配置
source /etc/profile
(5)校验安装成功
java -version
显示如下提示,则配置成功:
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
4. yum安装jdk
(1)查询可用安装版本
yum search java | grep -i --color jdk
(2)选择jdk8开发版进行安装
yum install -y java-1.8.0-openjdk-devel.x86_64
(3)验证安装结果
[root@localhost opt]# java -version
openjdk version "1.8.0_242"
OpenJDK Runtime Environment (build 1.8.0_242-b08)
OpenJDK 64-Bit Server VM (build 25.242-b08, mixed mode)
安装成功