Update alternatives ошибка нет альтернатив для java

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 get both plugins if they exist, work.

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?
The Following are results after update-java-alternatives

    $ 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

Перейти к контенту

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 get both plugins if they exist, work.

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?
The Following are results after update-java-alternatives

    $ 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

Хочу что бы JDK11 был выбран, по умолчанию, вручную. Ввожу команду:

 sudo update-java-alternatives --list

Мне выдает две версии 8 и 11

java-1.11.0-openjdk-amd64      1111       /usr/lib/jvm/java-1.11.0-openjdk-amd64
java-1.8.0-openjdk-amd64       1081       /usr/lib/jvm/java-1.8.0-openjdk-amd64

Далее выбираю java 11.

 sudo update-java-alternatives --set java-1.11.0-openjdk-amd64 --verbose

И начинают сыпаться ошибки.

resetting java alternatives
update-alternatives: ошибка: нет альтернатив для appletviewer
update-alternatives: ошибка: нет альтернатив для extcheck
update-alternatives: ошибка: нет альтернатив для idlj
update-alternatives: ошибка: нет альтернатив для javah
update-alternatives: ошибка: нет альтернатив для jhat
update-alternatives: ошибка: нет альтернатив для jsadebugd
update-alternatives: ошибка: нет альтернатив для mozilla-javaplugin.so
update-alternatives: ошибка: нет альтернатив для native2ascii
update-alternatives: ошибка: нет альтернатив для policytool
update-alternatives: ошибка: нет альтернатив для schemagen
update-alternatives: ошибка: нет альтернатив для wsgen
update-alternatives: ошибка: нет альтернатив для wsimport
update-alternatives: ошибка: нет альтернатив для xjc

Подозреваю нет альтернатив потому что этих компонентов просто нет в новой джаве, но тогда откуда они взялись?

ОС Дебиан.

The command update-java-alternatives -s jre-8-oracle-x64 is completely valid (found in documentation also here) but I get errors.
The package is also seen in the list of Java packages

root@masi:/home/masi# update-java-alternatives -l
java-1.7.0-openjdk-amd64 1071 /usr/lib/jvm/java-1.7.0-openjdk-amd64
jre-8-oracle-x64 317 /usr/lib/jvm/jre-8-oracle-x64

I do but cannot get jre-8-oracle-x64 work in my system without errors

# https://wiki.debian.org/JavaPackage
# http://unix.stackexchange.com/a/310787/16920
root@masi:/home/masi/Downloads# update-java-alternatives -s java-6-sun
update-java-alternatives: directory does not exist: /usr/lib/jvm/java-6-sun

root@masi:/home/masi/Downloads# ls /usr/lib/jvm/
default-java/                    java-7-openjdk-amd64/
java-1.7.0-openjdk-amd64/        jre-8-oracle-x64/
.java-1.7.0-openjdk-amd64.jinfo  .jre-8-oracle-x64.jinfo

root@masi:/home/masi/Downloads# update-java-alternatives -s jre-8-oracle-x64
update-alternatives: error: no alternatives for appletviewer
update-alternatives: error: no alternatives for extcheck
update-alternatives: error: no alternatives for idlj
update-alternatives: error: no alternatives for jar
update-alternatives: error: no alternatives for jarsigner
update-alternatives: error: no alternatives for javac
update-alternatives: error: no alternatives for javadoc
update-alternatives: error: no alternatives for javah
update-alternatives: error: no alternatives for javap
update-alternatives: error: no alternatives for jcmd
update-alternatives: error: no alternatives for jconsole
update-alternatives: error: no alternatives for jdb
update-alternatives: error: no alternatives for jhat
update-alternatives: error: no alternatives for jinfo
update-alternatives: error: no alternatives for jmap
update-alternatives: error: no alternatives for jps
update-alternatives: error: no alternatives for jrunscript
update-alternatives: error: no alternatives for jsadebugd
update-alternatives: error: no alternatives for jstack
update-alternatives: error: no alternatives for jstat
update-alternatives: error: no alternatives for jstatd
update-alternatives: error: no alternatives for native2ascii
update-alternatives: error: no alternatives for rmic
update-alternatives: error: no alternatives for schemagen
update-alternatives: error: no alternatives for serialver
update-alternatives: error: no alternatives for wsgen
update-alternatives: error: no alternatives for wsimport
update-alternatives: error: no alternatives for xjc

Using the auto-mode does not make sense; maybe, I should be deleting some packages in my system first

root@masi:/home/masi/Downloads# update-alternatives --auto java
update-alternatives: using /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java to provide /usr/bin/java (java) in auto mode

OS: Debian 8.5
Linux kernel: 4.6 of backports
Hardware: Asus Zenbook UX303UA
Java: JRE 8 version 102 Oracle x64

sudo update-alternatives --config java
update-alternatives: error: no alternatives for java

The installed java versions need to be added to update-alternatives:

adding jdk-11 with 10 priority :

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-11-openjdk-amd64/bin/java 10 

adding jdk-15 with 20 priority (suppose you have extracted the tarball to /usr/lib/jvm/ directory. In your case replace /usr/lib/jvm/jdk-15.0.2/bin/java with /usr/local/bin/jdk-15.0.2/bin/java)

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-15.0.2/bin/java 20

Check it:

 sudo update-alternatives --list java

/usr/lib/jvm/java-11-openjdk-amd64/bin/java
/usr/lib/jvm/jdk-15.0.2/bin/java

and

sudo update-alternatives --config java

sample output:

There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                         Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/jdk-15.0.2/bin/java              20        auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java   10        manual mode
  2            /usr/lib/jvm/jdk-15.0.2/bin/java              20        manual mode

Press <enter> to keep the current choice[*], or type selection number: 

Check the java version, in the above example the default version is jdk-15:

java --version

openjdk 15.0.2 2021-01-19
OpenJDK Runtime Environment (build 15.0.2+7-27)
OpenJDK 64-Bit Server VM (build 15.0.2+7-27, mixed mode, sharing)
sudo update-alternatives --config java
update-alternatives: error: no alternatives for java

The installed java versions need to be added to update-alternatives:

adding jdk-11 with 10 priority :

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-11-openjdk-amd64/bin/java 10 

adding jdk-15 with 20 priority (suppose you have extracted the tarball to /usr/lib/jvm/ directory. In your case replace /usr/lib/jvm/jdk-15.0.2/bin/java with /usr/local/bin/jdk-15.0.2/bin/java)

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-15.0.2/bin/java 20

Check it:

 sudo update-alternatives --list java

/usr/lib/jvm/java-11-openjdk-amd64/bin/java
/usr/lib/jvm/jdk-15.0.2/bin/java

and

sudo update-alternatives --config java

sample output:

There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                         Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/jdk-15.0.2/bin/java              20        auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java   10        manual mode
  2            /usr/lib/jvm/jdk-15.0.2/bin/java              20        manual mode

Press <enter> to keep the current choice[*], or type selection number: 

Check the java version, in the above example the default version is jdk-15:

java --version

openjdk 15.0.2 2021-01-19
OpenJDK Runtime Environment (build 15.0.2+7-27)
OpenJDK 64-Bit Server VM (build 15.0.2+7-27, mixed mode, sharing)

Inside a Debian 10 VM I have first installed OpenJDK 11, and it was all OK.
Then I have installed Oracle JDK 13 according to instructions posted in Computing for geeks, that means wget-ting the .deb file and install it with dpkg -i.

I have got no errors, but when running update-alternatives --config java I get this answer:

There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-11-openjdk-amd64/bin/java

Why? How can I switch from one JDK to the other?

dirdi's user avatar

dirdi

3,03114 silver badges34 bronze badges

asked Oct 2, 2019 at 9:41

Sandman42's user avatar

The alternatives are handled by pre- and post-install hooks. There seems to be no hook included in the package you downloaded, but you can easily add an alternative manually:

# update-alternatives --install /usr/bin/java java /path/to/OracleJDKs/java 2
# update-alternatives --install /usr/bin/javac javac /path/to/OracleJDKs/javac 2

Afterwards you should be able to select a Java version by running update-alternatives --config java and update-alternatives --config javac.

However, the java-package package always provided an easy way to install Oracle JDK on a Debian system. Since I have not used it for quiet a while I can not say if it is still compatible with current Java releases.

answered Oct 2, 2019 at 9:52

dirdi's user avatar

dirdidirdi

3,03114 silver badges34 bronze badges

0

Inside a Debian 10 VM I have first installed OpenJDK 11, and it was all OK.
Then I have installed Oracle JDK 13 according to instructions posted in Computing for geeks, that means wget-ting the .deb file and install it with dpkg -i.

I have got no errors, but when running update-alternatives --config java I get this answer:

There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-11-openjdk-amd64/bin/java

Why? How can I switch from one JDK to the other?

dirdi's user avatar

dirdi

3,09114 silver badges34 bronze badges

asked Oct 2, 2019 at 9:41

Sandman42's user avatar

The alternatives are handled by pre- and post-install hooks. There seems to be no hook included in the package you downloaded, but you can easily add an alternative manually:

# update-alternatives --install /usr/bin/java java /path/to/OracleJDKs/java 2
# update-alternatives --install /usr/bin/javac javac /path/to/OracleJDKs/javac 2

Afterwards you should be able to select a Java version by running update-alternatives --config java and update-alternatives --config javac.

However, the java-package package always provided an easy way to install Oracle JDK on a Debian system. Since I have not used it for quiet a while I can not say if it is still compatible with current Java releases.

answered Oct 2, 2019 at 9:52

dirdi's user avatar

dirdidirdi

3,09114 silver badges34 bronze badges

0

На самом деле вы можете просто добавить репозиторий partner в /etc/apt/sources.list:

deb http://archive.canonical.com/ubuntu lucid partner

Если вы не используете lucid, замените lucid на свой дистрибутив (вы можете получить его с помощью lsb_release -c).

Если у вас все еще есть проблема с плагином java, вы можете делать то, что я сделал, следуйте инструкциям здесь:

sudo update-alternatives --install /usr/lib/mozilla/plugins/mozilla-javaplugin.so mozilla-javaplugin.so /usr/lib/jvm/java-6-sun/jre/lib/amd64/libnpjp2.so 1

Если вы не на 64 битах , замените amd64 на i386.

ответ дан Anthony O.
25 May 2018 в 16:48

поделиться

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

Понравилась статья? Поделить с друзьями:
  • Uo121 ошибка форд
  • Upc exe ошибка uplay
  • Usb flash ошибка ввода вывода
  • Uo121 ошибка приора
  • Upc exe ошибка ubisoft