1、which java(查看JDK的安装路径)
2、检查下自带的jdk命令:
rpm -qa |grep java
rpm -qa |grep jdk
rpm -qa |grep gcj
如果没有输入信息表示没有安装。
3、如果有信息进行卸载
rpm -qa | grep java | xargs rpm -e --nodeps 批量卸载所有带有jdk的文件 这句命令的关键字是jdk
4、官网进行下载对应的jdk
https://www.oracle.com/java/technologies/downloads/#java8
5、环境变量配置
vim /etc/profile
#JAVA
export JAVA_HOME=/root/tools/jdk/usr/java/jdk1.8.0_311-aarch64
export PATH=
J
A
V
A
H
O
M
E
/
b
i
n
:
JAVA_HOME/bin:
JAVAHOME/bin:PATH
export CLASSPATH=.:
J
A
V
A
H
O
M
E
/
l
i
b
/
d
t
.
j
a
r
:
JAVA_HOME/lib/dt.jar:
JAVAHOME/lib/dt.jar:JAVA_HOME/lib/tools.jar
source /etc/profile
6、java -version 如果出现以下报错
Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object
解决办法:分别把
/opt/jdk1.6.0_15/lib/ tools.pack 转为 tools.jar
/opt/jdk1.6.0_15/jre/lib/rt.pack 转为 rt.jar
[root@localhost lib]# pwd
/opt/jdk1.6.0_15/lib
[root@localhost lib]# unpack200 tools.pack tools.jar
[root@localhost lib]# ls
ct.sym htmlconverter.jar jconsole.jar orb.idl tools.jar tools.pack.bak
dt.jar ir.idl jexec sa-jdi.jar tools.pack visualvm
[root@localhost lib]# pwd
/opt/jdk1.6.0_15/jre/lib
[root@localhost lib]# unpack200 rt.pack rt.jar
done~
转载:https://www.daimajiaoliu.com/daima/4e47283cd900404