我在全新安装的 Ubuntu 18.04 上。我做了一个sudo apt-get install default-jdk
。结果:
java --version
openjdk 10.0.2 2018-07-17
OpenJDK Runtime Environment (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.1)
OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.1, mixed mode)
现在我做到了sudo apt-get purge default-jdk
。结果:
java --version
openjdk 10.0.2 2018-07-17
OpenJDK Runtime Environment (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.1)
OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.1, mixed mode)
为什么 OpenJDK 仍然存在?
答案1
default-jdk
在 18.04 中有以下描述:
Description: Standard Java or Java compatible Development Kit
This dependency package points to the Java runtime, or Java compatible
development kit recommended for this architecture, which is
openjdk-11-jdk for amd64.
计算结果apt-cache depends default-jdk
如下:
default-jdk
Depends: default-jre
Depends: default-jdk-headless
Depends: openjdk-11-jdk
结果apt-cache rdepends default-jdk
表明 openjdk-11-jdk 不依赖于默认 jdk。默认 jdk指向 Java 运行时或 Java 兼容开发工具包,但卸载默认 jdk不会卸载这两个包。
删除安装的软件包默认 jdk,运行以下命令:
sudo apt remove openjdk-11-jre-headless openjdk-11-jre openjdk-11-jdk-headless openjdk-11-jdk