centos7 安装jdk1.8

centOS7环境下安装jdk1.8
1.首先下载jdk1.8 去官网下载jdk:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
我这里下载的是 jdk-8u291-linux-x64.tar.gz

 

2.解压到指定的目录 解压命令
[root@rac01 soft]#mkdir -p /usr/local/java
[root@rac01 soft]#tar -zxvf jdk-8u291-linux-x64.tar.gz -C /usr/local/java/

 

3.修改配置文件,让其生效
编辑/etc/下的profile文件,配置环境变量

[root@rac02 soft]#  vi /etc/profile
export JAVA_HOME=/usr/local/java/jdk1.8.0_291
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH

 

[root@rac02 soft]# source /etc/profile

 

4.测试
[root@rac01 ~]# java -version
java version "1.8.0_291"
Java(TM) SE Runtime Environment (build 1.8.0_291-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.291-b10, mixed mode)

 

posted @ 2021-05-17 09:15  slnngk  阅读(354)  评论(0编辑  收藏  举报