1.jdK一般放在/usr/java目录下
下载链接:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html [root@hadoop java]# mkdir -p /usr/java [root@hadoop java]# cd /usr/java/ [root@hadoop java]# tar -xzvf jdk-8u171-linux-x64.gz 解压后可能用户用户组不对 可使用chown -R root:root jdk1.8.0_171 更改
2.更改环境变量
[root@hadoop java]# vi /etc/profile export JAVA_HOME=/usr/java/jdk1.8.0_171 export PATH=$JAVA_HOME/bin:$PATH 之后source /etc/profile生效
3.验证环境
[root@hadoop java]# which java /usr/java/jdk1.8.0_171/bin/java [root@hadoop java]# java -version java version "1.8.0_171" Java(TM) SE Runtime Environment (build 1.8.0_171-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)