系统中不存在 JDK,但系统提示需要删除

系统中不存在 JDK,但系统提示需要删除

因此我尝试构建 Oracle 提供的 .rpm 文件。安装并非 100% 成功,因此我想卸载它,然后以 openjdk 的简单方式进行安装,但现在我无法安装任何东西,因为 linux 告诉我 jdk 在系统上,但实际上没有。Linux 尝试删除它,但未能阻止我安装任何东西:

例如如果我尝试

sudo apt install openjdk-7-jdk

它给了我这个:

0 upgraded, 38 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 0 B/62,5 MB of archives.
After this operation, 162 MB disk space will be freed.

Do you want to continue? [Y/n] y
Extracting templates from packages: 100%
(Reading database ... 183637 files and directories currently installed.)
Removing jdk1.8.0-101 (1.8.0101-fcs-1) ...
find: `/usr/java/*': No such file or directory
/var/lib/dpkg/info/jdk1.8.0-101.postrm: line 586: /usr/sbin/alternatives: No such file or directory
/var/lib/dpkg/info/jdk1.8.0-101.postrm: line 598: /usr/sbin/alternatives: No such file or directory
dpkg: error processing package jdk1.8.0-101 (--remove):
subprocess installed post-removal script returned error exit status 127
Errors were encountered while processing:
jdk1.8.0-101
E: Sub-process /usr/bin/dpkg returned an error code (1)

答案1

问题已解决。

分析了出现错误的文件并找出我做错的地方。

我在 jdk 损坏时卸载了 java。结果,当我尝试卸载 jdk 时,它会运行第 586 行和第 598 行上的函数,该函数引用了我已删除的 java 的替代版本。

由于我已经卸载了 java 并且没有任何问题,那些函数毫无用处,所以我只是编辑了函数的内容,以防脚本的其余部分需要它们:

echo "Hello World"

正如预期的那样,当我卸载 jdk 时,它给了我两次“Hello World”。现在已完全卸载。无论如何,感谢大家的帮助。

相关内容