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?
Your first command was wrong, I think; it should have been:
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 useopenjdk-11+28-amd64
hereCreate a shell script to udpate alternatives automatically
I call it
jdk-11.sh
Then make
jdk-11.sh
executable, and runto add alternatives for the new jdk-11
Switch to this jdk-11
then switch to that alternative with the help of
update-java-alternatives
We need a helper file called
.openjdk-11+28.jinfo
inside/usr/lib/jvm
Then run
To roll-back to ubuntu package