jdk 安裝 java/lang/NoClassDefFoundError: java/lang/Object 解決辦法

來源:本站原創 Linux 超過720 views圍觀 0條評論

[[email protected]_master ~]# java
Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object

 

先確認環境變量對不對

—–安裝方式

rpm -ivh /etc/ansible/roles/base/files/jdk-8u121-linux-x64.rpm
echo "#java——–" >> /etc/profile
echo "export JAVA_HOME=/usr/java/jdk1.8.0_121" >> /etc/profile
echo "export JRE_HOME=/usr/java/jdk1.8.0_121/jre" >> /etc/profile
#echo "export CLASSPATH=$JAVA_HOME/lib/" >> /etc/profile
echo "export CLASSPATH=$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar" >> /etc/profile
echo "export PATH=$PATH:$JAVA_HOME/bin" >> /etc/profile

source /etc/profile

—-檢查環境變量

#java——–
export JAVA_HOME=/usr/java/jdk1.8.0_121
export JRE_HOME=/usr/java/jdk1.8.0_121/jre
export CLASSPATH=/usr/java/jdk1.8.0_121/jre/lib/rt.jar:/usr/java/jdk1.8.0_121/lib/dt.jar:/usr/java/jdk1.8.0_121/lib/tools.jar
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/bin:/usr/java/jdk1.8.0_121/bin

—解決方法

環境變量不錯的情況下.使用如下命令
[[email protected]_master ~]# ll /usr/java/jdk1.8.0_121/lib/
total 26972

-rw-r–r–. 1 root root  5155369 Dec 12  2016 tools.pack   —–這個文件不對,需要重新打包

cd /usr/java/jdk1.8.0_121/lib/
[[email protected]_master lib]# unpack200 tools.pack tools.jar   —-解決命令

[[email protected]_master lib]# cd /usr/java/jdk1.8.0_121/jre/lib/
-rw-r–r–.  1 root root 17585004 Dec 12  2016 rt.pack   —–這個文件不對,需要重新打包
[[email protected]_master lib]# unpack200 rt.pack rt.jar —-解決命令
[[email protected]_master lib]# java –version    ———-恢復正常
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
[[email protected]_master lib]#

文章出自:CCIE那點事 http://www.qdxgqk.live/ 版權所有。本站文章除注明出處外,皆為作者原創文章,可自由引用,但請注明來源。 禁止全文轉載。
本文鏈接:http://www.qdxgqk.live/?p=3714轉載請注明轉自CCIE那點事
如果喜歡:點此訂閱本站
?
?
萌宠夺宝游戏