Java

為什麼不能刪除java版本?

  • September 10, 2021

刪除 openjdk-17-jre 和 jdk :

sudo apt remove  openjdk-17-jre openjdk-17-jdk 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
 openjdk-17-jdk-headless
Use 'sudo apt autoremove' to remove it.
The following packages will be REMOVED:
 openjdk-17-jdk openjdk-17-jre
0 upgraded, 0 newly installed, 2 to remove and 1 not upgraded.
After this operation, 9,250 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 295782 files and directories currently installed.)
Removing openjdk-17-jdk:amd64 (17~19-1) ...
update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/jconsole to provide /usr/bin/jconsole (jconsole) in auto mode
Removing openjdk-17-jre:amd64 (17~19-1) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
debian@debian:~/Downloads$ java -version
openjdk version "17-ea" 2021-09-14
OpenJDK Runtime Environment (build 17-ea+19-Debian-1)
OpenJDK 64-Bit Server VM (build 17-ea+19-Debian-1, mixed mode, sharing)
debian@debian:~/Downloads$ sudo apt autoremove
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED:
 openjdk-17-jdk-headless
0 upgraded, 0 newly installed, 1 to remove and 1 not upgraded.
After this operation, 248 MB disk space will be freed.
Do you want to continue? [Y/n] y

重新啟動並再次登錄。

java -version
openjdk version "17-ea" 2021-09-14
OpenJDK Runtime Environment (build 17-ea+19-Debian-1)
OpenJDK 64-Bit Server VM (build 17-ea+19-Debian-1, mixed mode, sharing)

為什麼不能刪除java版本?

您還需要刪除openjdk-17-jre-headless

sudo apt purge openjdk-17-jre-headless

由於這沒有標記為可自動刪除,因此可能還有其他軟體包仍然依賴它;上面的命令會告訴你是否是這種情況。

引用自:https://unix.stackexchange.com/questions/668487