4

I'm on a fresh Ubuntu 18.04 install. I did a sudo apt-get install default-jdk. Result:

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)

Now I did sudo apt-get purge default-jdk. Result:

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)

Why is OpenJDK still there?

5

default-jdk in 18.04 has the following description:

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. 

The results of apt-cache depends default-jdk are as follows:

default-jdk
  Depends: default-jre
  Depends: default-jdk-headless
  Depends: openjdk-11-jdk

The results of apt-cache rdepends default-jdk show that openjdk-11-jdk does not depend on default-jdk. default-jdk points to a Java runtime or Java compatible development kit, but uninstalling default-jdk does not uninstall either of these packages.

To remove the packages installed by default-jdk, run the following command:

sudo apt remove openjdk-11-jre-headless openjdk-11-jre openjdk-11-jdk-headless openjdk-11-jdk  
4
  • Since default-jdk depends on openjdk-11-jdk, then wouldn't removing default-jdk followed by a sudo apt-get autoremove accomplish the same? – You'reAGitForNotUsingGit Sep 17 '18 at 14:18
  • @AndroidDev I replied to your comment by editing my answer. My reply is in the 5th paragraph. – karel Sep 17 '18 at 14:31
  • After sudo apt-get install default-jdk I use apt list --installed | grep openj to see that the packages openjdk-11-jre-headless, openjdk-11-jre, openjdk-11-jdk-headless and openjdk-11-jdk are installed. I use apt list --installed | grep openj again after a sudo apt-get purge default-jdk to see that all 4 packages are still there. After sudo apt-get autoremove the 2 jdk packages are gone but the 2 jre packages are still there! – Robert Sep 17 '18 at 14:46
  • oh I should add that in the meantime I have done a sudo apt-get install openjdk-8-jdk (which has solved my actual problem which I haven't described). So maybe that's the reason why he keeps the jre11 packages despite an autoremove? Which would be weird because why would OpenJDK8 want to have those packages. Anyway, now I have both, default-jdk and openjdk-8-jdk. I switch between the two via sudo update-java-alternatives. – Robert Sep 17 '18 at 15:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.