Removing package openjdk-9-jre-headless does not delete/change links in Debian Alternatives System

Bug #1700292 reported by mrkramps on 2017-06-24
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
openjdk-9 (Ubuntu)
Undecided
Unassigned

Bug Description

This issue affects Ubuntu 16.04.

When having openjdk-8-jre-headless (8u131-b11-0ubuntu1.16.04.2) installed and installing openjdk-9-jre-headless (9~b114-0ubuntu1) all links in the Debian Alternatives System are changed pointing to JRE 9:

$ sudo apt-get install openjdk-9-jre-headless
[…]
Setting up openjdk-9-jre-headless:amd64 (9~b114-0ubuntu1) ...
update-alternatives: using /usr/lib/jvm/java-9-openjdk-amd64/bin/rmid to provide /usr/bin/rmid (rmid) in auto mode
update-alternatives: using /usr/lib/jvm/java-9-openjdk-amd64/bin/java to provide /usr/bin/java (java) in auto mode
update-alternatives: using /usr/lib/jvm/java-9-openjdk-amd64/bin/keytool to provide /usr/bin/keytool (keytool) in auto mode
update-alternatives: using /usr/lib/jvm/java-9-openjdk-amd64/bin/jjs to provide /usr/bin/jjs (jjs) in auto mode
update-alternatives: using /usr/lib/jvm/java-9-openjdk-amd64/bin/pack200 to provide /usr/bin/pack200 (pack200) in auto mode
update-alternatives: using /usr/lib/jvm/java-9-openjdk-amd64/bin/rmiregistry to provide /usr/bin/rmiregistry (rmiregistry) in auto mode
update-alternatives: using /usr/lib/jvm/java-9-openjdk-amd64/bin/unpack200 to provide /usr/bin/unpack200 (unpack200) in auto mode
update-alternatives: using /usr/lib/jvm/java-9-openjdk-amd64/bin/orbd to provide /usr/bin/orbd (orbd) in auto mode
update-alternatives: using /usr/lib/jvm/java-9-openjdk-amd64/bin/servertool to provide /usr/bin/servertool (servertool) in auto mode
update-alternatives: using /usr/lib/jvm/java-9-openjdk-amd64/bin/tnameserv to provide /usr/bin/tnameserv (tnameserv) in auto mode
update-alternatives: using /usr/lib/jvm/java-9-openjdk-amd64/lib/jexec to provide /usr/bin/jexec (jexec) in auto mode
[…]

If removing/purging openjdk-9-jre-headless the links are not changed back to JRE 8:

$ sudo apt-get purge openjdk-9-jre-headless
[…]
Removing openjdk-9-jre-headless:amd64 (9~b114-0ubuntu1) ...
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/jexec to provide /usr/bin/jexec (jexec) in auto mode
Purging configuration files for openjdk-9-jre-headless:amd64 (9~b114-0ubuntu1) ...
dpkg: warning: while removing openjdk-9-jre-headless:amd64, directory '/usr/lib/jvm/java-9-openjdk-amd64/lib/amd64/server' not empty so not removed
[…]

Checking Java version outputs:

$ java -version
The program 'java' can be found in the following packages:
 * default-jre
 * gcj-5-jre-headless
 * openjdk-8-jre-headless
 * gcj-4.8-jre-headless
 * gcj-4.9-jre-headless
 * openjdk-9-jre-headless
Try: sudo apt install <selected package>

Reinstalling openjdk-8-jre-headless does not help:

$ sudo install --reinstall openjdk-8-jre-headless
[…]
Setting up openjdk-8-jre-headless:amd64 (8u131-b11-0ubuntu1.16.04.2) ...
update-alternatives: warning: alternative /usr/lib/jvm/java-9-openjdk-amd64/bin/java (part of link group java) doesn't exist; removing from list of alternatives
update-alternatives: warning: alternative /usr/lib/jvm/java-9-openjdk-amd64/bin/java (part of link group java) doesn't exist; removing from list of alternatives
update-alternatives: warning: alternative /usr/lib/jvm/java-9-openjdk-amd64/bin/java (part of link group java) doesn't exist; removing from list of alternatives
update-alternatives: warning: alternative /usr/lib/jvm/java-9-openjdk-amd64/bin/java (part of link group java) doesn't exist; removing from list of alternatives
update-alternatives: warning: alternative /usr/lib/jvm/java-9-openjdk-amd64/bin/java (part of link group java) doesn't exist; removing from list of alternatives
update-alternatives: warning: alternative /usr/lib/jvm/java-9-openjdk-amd64/bin/java (part of link group java) doesn't exist; removing from list of alternatives
update-alternatives: warning: alternative /usr/lib/jvm/java-9-openjdk-amd64/bin/java (part of link group java) doesn't exist; removing from list of alternatives
update-alternatives: warning: alternative /usr/lib/jvm/java-9-openjdk-amd64/bin/java (part of link group java) doesn't exist; removing from list of alternatives
update-alternatives: warning: alternative /usr/lib/jvm/java-9-openjdk-amd64/bin/java (part of link group java) doesn't exist; removing from list of alternatives
update-alternatives: warning: alternative /usr/lib/jvm/java-9-openjdk-amd64/bin/java (part of link group java) doesn't exist; removing from list of alternatives
[…]

Checking Java version again still outputs:

$ java -version
The program 'java' can be found in the following packages:
 * default-jre
 * gcj-5-jre-headless
 * openjdk-8-jre-headless
 * gcj-4.8-jre-headless
 * gcj-4.9-jre-headless
 * openjdk-9-jre-headless
Try: sudo apt install <selected package>

Checking entry in Alternatives System outputs:

$ update-alternatives --display java
update-alternatives: warning: alternative /usr/lib/jvm/java-9-openjdk-amd64/bin/java (part of link group java) doesn't exist; removing from list of alternatives
java - auto mode
  link best version is /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
  link currently points to /usr/lib/jvm/java-9-openjdk-amd64/bin/java
  link java is /usr/bin/java
  slave java.1.gz is /usr/share/man/man1/java.1.gz
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java - priority 1081
  slave java.1.gz: /usr/lib/jvm/java-8-openjdk-amd64/jre/man/man1/java.1.gz

Current workaround is to manually change the links back to JRE 8:

$ for a in rmid java keytool jjs pack200 rmiregistry unpack200 orbd servertool tnameserv jexec ; do sudo update-alternatives --auto "$a" ; done

Or purge and reinstall the complete JRE 8 which will also affect all packages depending on it.

EDIT: Removed wrong semicolon in workaround (as mentioned in comment #1)

NOTE: This issue does not affect Ubuntu 17.04 (openjdk-8-jre-headless 8u131-b11-0ubuntu1.17.04.1 and openjdk-9-jre-headless 9~b161-1).

mrkramps (mrkramps) wrote :

I am sorry, there is a typo (a semicolon where should be none) in the for loop of the workaround. The correct command should be:

$ for a in rmid java keytool jjs pack200 rmiregistry unpack200 orbd servertool tnameserv jexec ; do sudo update-alternatives --auto "$a" ; done

mrkramps (mrkramps) on 2017-06-24
description: updated
mrkramps (mrkramps) on 2017-06-25
description: updated
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers