12

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

4
  • So you have Java 8 as default now and solved your problem. Mar 5 '19 at 11:31
  • 1
    Although those read like error messages, they are more like warnings. You can ignore them because the update-java-alternatives command has properly reconfigured the alternatives to enable all of the java components (including java and javac if its a jdk) to the desired version. @Kulfy made this comment below but it wasn't very obvious
    – Lee Meador
    Mar 6 '20 at 17:15
  • @Sancho, did you solve this issue? I have exatly the same problem on Ubuntu eoan.
    – codyLine
    Apr 20 '20 at 13:49
  • @codyLine - I am not sure... this happened some time ago. Apr 20 '20 at 14:54
10

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.

7
  • 2
    It seems update-java-alternative does the same as update-alternatives --config java, and more. So I wouldn't expect this to solve the issue. Perhaps at best it doesn't attempt performing the actions which lead to the messages, but then it would possibly be not useful anyway. Mar 4 '19 at 23:17
  • Have you tried it? Mar 5 '19 at 6:17
  • No. Would you mind posting the exact procedure to follow? How should I check if the ending result is ok (in addition to getting rid of the error message)? Please see updated OP; the actions implied by your command seem already executed by what I did. Mar 5 '19 at 10:40
  • @sancho.s If you want to check that if alternatives are changed, run java -version
    – Kulfy
    Mar 5 '19 at 11:17
  • @Kulfy - Already did that, I will add it. Mar 5 '19 at 11:22
0

jre-headless is okay if the java app you want to run has no gui. update-alternatives --config java has potential inconsistent java env issue. See Setting JDK 7 as default

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.