1.yum方式安装:
yum -y install java-1.8.0-openjdk
yum -y install git
2.jdk源码方式安装,下载源码包长传至centos
下载:
https://download.oracle.com/otn/java/jdk/8u301-b09/d3c52aa6bfa54d3ca74e617f18309292/jdk-8u301-linux-x64.tar.gz?AuthParam=1630159931_bc59675cc38cbfb2c92198d85cc6a47f
创建安装目录
mkdir /usr/local/java/
解压至安装目
tar -zxvf jdk-8u301-linux-x64.tar.gz -C /usr/local/java/
设置环境变量
vim /etc/profile
打开文件
vim /etc/profile
在末尾添加
export JAVA_HOME=/usr/local/java/jdk1.8.0_171
export JRE_HOME=
J
A
V
A
H
O
M
E
/
j
r
e
e
x
p
o
r
t
C
L
A
S
S
P
A
T
H
=
.
:
{JAVA_HOME}/jre export CLASSPATH=.:
JAVAHOME/jreexportCLASSPATH=.:{JAVA_HOME}/lib:
J
R
E
H
O
M
E
/
l
i
b
e
x
p
o
r
t
P
A
T
H
=
{JRE_HOME}/lib export PATH=
JREHOME/libexportPATH={JAVA_HOME}/bin:$PATH
使环境变量生效
source /etc/profile
参考:
https://www.cnblogs.com/telwanggs/p/11546751.html
https://www.cnblogs.com/stulzq/p/9286878.html