(1)创建安装目录
mkdir /usr/local/java/
(2)解压至安装目录
tar -zxvf jdk-8u171-linux-x64.tar.gz -C /usr/local/java/
(3)打开文件
vim /etc/profile
(4)在末尾添加
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
(5)使环境变量生效
source /etc/profile
添加软链接
ln -s /usr/local/java/jdk1.8.0_171/bin/java /usr/bin/java
(6)检查
java -version
linux安装jdk
最新推荐文章于 2024-08-22 17:10:39 发布