Linux版本:Redhat 7.6 x64

一、下载JDK安装包

从oracle官网下载JDK:Java SE Development Kit 8 - Downloads

选择合适的版本,本文选择 jdk-8u271-linux-x64.rpm 。

二、安装

执行rpm安装:

snippet.bash
[root@bogon software]# rpm -i ./jdk-8u271-linux-x64.rpm 
警告:./jdk-8u271-linux-x64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID ec551f03: NOKEY
Unpacking JAR files...
	tools.jar...
	plugin.jar...
	javaws.jar...
	deploy.jar...
	rt.jar...
	jsse.jar...
	charsets.jar...
	localedata.jar...

三、配置环境变量

配置环境:

snippet.bash
[root@bogon software]# vi /etc/profile
# Java:
export JAVA_HOME=/usr/java/jdk1.8.0_271-amd64/
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

重新登录,校验环境变量是否生效:

snippet.bash
[root@bogon ~]# which javaws
/usr/java/jdk1.8.0_271-amd64/bin/javaws