centos下安装jdk

1. 查询yum库中都有哪些jdk版本

yum search java|grep jdk

2.选择版本,进行安装

yum install java-1.8.0-openjdk

3. 配置环境变量
vi /etc/profile
添加
#set java environment
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.144-0.b01.el7_4.x86_64
JRE_HOME=$JAVA_HOME/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 

4. 让修改生效

[root@admin java]# source /etc/profile

5. 验证
[root@admin home]# java -version
openjdk version "1.8.0_144"
OpenJDK Runtime Environment (build 1.8.0_144-b01)
OpenJDK 64-Bit Server VM (build 25.144-b01, mixed mode)
[root@admin home]# 

你可能感兴趣的:(centos下安装jdk)