chentos7 安装jdk1.8(二进制安装)
首先下载jdk1.8 去官网下载jdk:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
解压到指定的目录 解压命令
#解压压缩包 [yuyongxr@instance-2 ~] tar -zxvf jdk-8u221-linux-x64.tar.gz #将文件移动到指定目录 [yuyongxr@instance-2 ~] sudo mv jdk1.8.0_221/ /usr/local/
然后修改配置文件,设置环境变量,编辑/etc/下的profile文件
#在最后追加以下配置 [yuyongxr@instance-2 ~]vi /etc/profile export JAVA_HOME=/usr/local/jdk1.8.0_221 export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=${JAVA_HOME}/bin:$PATH
使/etc/profile生效
[yuyongxr@instance-2 ~]$ source /etc/profile
测试
[yuyongxr@instance-2 ~]$ java -version java version "1.8.0_221" Java(TM) SE Runtime Environment (build 1.8.0_221-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)