centos上安装jdk

前端之家收集整理的这篇文章主要介绍了centos上安装jdk前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_404_1@1)下载jdk:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

@H_404_1@2)放置到/usr/local/software/java 目录下,并解压 tar-xzv -f jdk*.gz

@H_404_1@3)配置环境变量

@H_404_1@vim /etc/profile

@H_404_1@追加如下内容并保存:

@H_404_1@export JAVA_HOME=/usr/local/software/java/jdk1.8.0_162
export JRE_HOME=/usr/local/software/java/jdk1.8.0_162/jre
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin

@H_404_1@4)将java命令添加到bin

@H_404_1@5)将javac命令添加到bin

@H_404_1@6)选择jdk版本;

[root@localhost jdk1.8.0_162]# update-alternatives --install /usr/bin/java java /usr/local/software/java/jdk1.8.0_162/ 300
[root@localhost jdk1.8.0_162]# update-alternatives --install /usr/bin/javac javac /usr/local/software/java/jdk1.8.0_162/bin/javac 300
[root@localhost jdk1.8.0_162]# update-alternatives --config java

共有 3 个程序提供“java”。

  选择    命令
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.7.0-openjdk/bin/java
   2           /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
   3           /usr/local/software/java/jdk1.8.0_162/

按 Enter 来保存当前选择[+],或键入选择号码:3
@H_404_1@7)启用刚才的环境变量;

@H_404_1@source /etc/profile

@H_404_1@8)验证: java -version

[root@localhost jdk1.8.0_162]# source /etc/profile
[root@localhost jdk1.8.0_162]# 
[root@localhost jdk1.8.0_162]# java -version
java version "1.8.0_162"
Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) Server VM (build 25.162-b12,mixed mode)
原文链接:https://www.f2er.com/centos/374462.html

猜你在找的CentOS相关文章