Java 11 to 8: update-alternatives: error: no alternatives for mozilla-javaplugin.so

I have Java 11 and 8 in my Ubuntu 18.04, side by side. I mean to set Java 8 as the default.

What I get:

$ sudo update-java-alternatives --set /usr/lib/jvm/java-1.8.0-openjdk-amd64
update-alternatives: error: no alternatives for mozilla-javaplugin.so
update-java-alternatives: plugin alternative does not exist: /usr/lib/jvm/java-8-openjdk-amd64/lib/IcedTeaPlugin.so

How can I fix this? (I mean to get both plugins if they exist, or to know that they do not exist).

I am not sure if using (see this)

sudo update-java-alternative —jre-headless -s java-1.8.0-openjdk-amd64

is ok, so I did not try it. Could it break anything?

What I have now (after update-java-alternatives) is

$ sudo update-alternatives --config java
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

$ java -version
openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-8u191-b12-2ubuntu0.18.04.1-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)

This is the opposite change from

update-alternatives: error: no alternatives for mozilla-javaplugin.so

https://ubuntuforums.org/showthread.php?t=2402155

Related:

https://serverfault.com/questions/814064/set-jdk-8-as-the-default-java-on-debian-8


Solution 1:

You can select the default Java Version by running the following command:

sudo update-alternatives --config java

Then select the Java Installation you want to use per default by typing the selection number. You can check the default Java Version by running java -version. It should print something similar to the following:

openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-8u191-b12-2ubuntu0.18.04.1-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)

Hope that helps.