The problem comes from an improper java installation (e.g. an installation done without admin rights or by simply unzipping tools.zip).
You can either uninstall, then reinstall Java with an installer and/or more privileges or try the following:
Check in your JDK folder for *.pack
files in jre/lib
andjre/lib/ext
such asrt.pack
(the default location is c:\nameof_jdk_folder\jre\lib
for Microsoft Windows and/usr/java/lib
for Unix/GNU Linux)
Those *.pack
files need to be unpacked to .jar
files using this command:
-
For Windows:
%JAVA_HOME%\bin\unpack200 -r -v -l "" rt.pack rt.jar
-
For *nix, a similar command line will unpack the files:
cd /usr/java/lib
/usr/bin/unpack200 rt.pack rt.jar
and repeat that step with all of the *.pack files and relaunch your program.
亲自尝试下:
sudo unpack200 rt.pack rt.jar
rt.jar的问题搞定,java -verison不再报错,但是还有其他pack没有搞定呢。
比如,javac还有类似的问题,一个个搞麻烦,并且不是正途。根本原因应该在安装过程。
于是,检查安装步骤, 这次加上参数v, 便于查看提示信息
sudo alien -iv ./jdk*rpm
发现alien在执行rpm时有警告:
Warning: Use the --script parameter to include the scripts