5

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

  • So you have Java 8 as default now and solved your problem. – Samuel Philipp Mar 5 '19 at 11:31
6

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.

  • 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. – sancho.s Reinstate Monica Mar 4 '19 at 23:17
  • Have you tried it? – Samuel Philipp 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. – sancho.s Reinstate Monica 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. – sancho.s Reinstate Monica 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.