Centos用yum安装jdk1.8.0

前端之家收集整理的这篇文章主要介绍了Centos用yum安装jdk1.8.0前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。


1.查看yum库中都有哪些jdk版本(暂时只发现了openjdk)


[root@localhost ~]# 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-demo.x86_64 : OpenJDK Demos
java-1.8.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.8.0-openjdk-headless.x86_64 : OpenJDK Runtime Environment
java-1.8.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.8.0-openjdk-src.x86_64 : OpenJDK Source Bundle
ldapjdk.x86_64 : The Mozilla LDAP Java SDK

2.选择版本,进行安装


//选择1.7版本进行安装
[root@localhost ~]# yum install java-1.7.0-openjdk

//安装完之后,默认的安装目录是在: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75.x86_64

3.设置环境变量


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

在profile文件添加如下内容

set java environment

JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75.x86_64
JRE_HOME= JAVAHOME/jreCLASSPATH=.: JAVA_HOME/lib/dt.jar: JAVAHOME/lib/tools.jar: JRE_HOME/lib
PATH= PATH: JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH

修改生效
[root@localhost java]# source /etc/profile

4.验证


[root@localhost java]# java -version
openjdk version “1.8.0_151”
OpenJDK Runtime Environment (build 1.8.0_151-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12,mixed mode)
成功!

原文链接:https://www.f2er.com/centos/375433.html

猜你在找的CentOS相关文章