Can Not Install Jdk11 Using Update-Alternatives --Install

to try out the new features of jdk11 I installed it into /opt/ and want to use it using update-alternatives, like so:

sudo update-alternatives --install /etc/alternatives/java OpenJDK-11 /opt/jdk-11/bin/java 1102

which returns:

update-alternatives: using /opt/jdk-11/bin/javac to provide /etc/alternatives/java (OpenJDK-11) in auto mode

However, when I do

$ sudo update-alternatives --config java

I don't see the jdk I just installed. Instead I get a warning and the already existing choices:

update-alternatives: warning: /etc/alternatives/java has been changed (manually or by a script); switching to manual updates only
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1101      auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1101      manual mode
  2            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode

What does the warning mean, and why is it in fact showing both auto and manual mode entries? And why is my jdk11 not in there?

5

1 Answer

Your first command was wrong, I think; it should have been:

sudo update-alternatives /usr/bin/java java /opt/jdk-11/bin/java 1102

and the same for all the others executables of the jdk.

how to do it

Install jdk-11

First install jdk-11 inside a directory in /usr/lib/jvm. We will use openjdk-11+28-amd64 here

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.