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

sudo update-alternatives --config java

Select the Java Installation you want to use per default by typing the selection number. 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)
Answer from Samuel Philipp on askubuntu.com
🌐
Medium
irsyadsec.medium.com › java-not-found-in-update-alternatives-config-java-after-installing-java-on-linux-d88e499e5c4f
Java not found in “update-alternatives — config java” after installing java on linux | by Irsyad Muhammad Fawwaz | Medium
May 4, 2023 - Now that we have the path of Java 18, we need to register it as an alternative using the update-alternatives command. Enter the following command in your terminal: sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/<jdk-folder>/bin/java 1 · This command registers Java 18 as an alternative with a priority of 1. If you have multiple Java versions installed on your system, you can set a higher priority for Java 18 by changing the number at the end of the command.
Discussions

How to update-java-alternatives successfully to Oracle's one in Debian? - Unix & Linux Stack Exchange
Stack Exchange network consists ... for developers to learn, share their knowledge, and build their careers. Visit Stack Exchange ... Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... The command update-java-alternatives -s jre-8-oracle-x64 is completely valid (found in documentation also here) but I get errors... More on unix.stackexchange.com
🌐 unix.stackexchange.com
September 19, 2016
On Debian 8 update-java-alternatives generate multiple errors
$ sudo update-java-alternatives -s java-1.8.0-openjdk-amd64 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 ... More on github.com
🌐 github.com
6
December 19, 2017
update-alternatives: error: no alternatives for mozilla-javaplugin.so
When I build the environment of Maskfusion as the build.sh described and execute the command: sudo update-java-alternatives -s java-1.8.0-openjdk-amd64, I had meet a error that It is update-alternatives: error: no alternatives for mozilla-javaplugin.so , I can't solve this error . More on github.com
🌐 github.com
5
December 7, 2018
linux - update-alternatives: error: alternative /usr/lib/jvm/jdk1.8.0_312/bin/java for java not registered; not setting - Stack Overflow
default: Updating eventually the correct version of Java... update-alternatives: error: alternative /usr/lib/jvm/jdk1.8.0_312/bin/java for java not registered; not setting More on stackoverflow.com
🌐 stackoverflow.com
🌐
Django CAS
djangocas.dev › blog › linux › switch-java-version-with-update-alternatives
Switch Java Version with update-alternatives - django-cas-ng
July 7, 2024 - If you want to configure non-interactively you can use the --set option instead. For example, in script you donot want user input. You can use update-alternatives --set java <path> to update java version directly.
🌐
SUSE
documentation.suse.com › sles › 15-SP6 › html › SLES-all › cha-update-alternative.html
update-alternatives: managing multiple versions of commands and files | Administration Guide | SLES 15 SP6
March 30, 2026 - If you see the same path (in our example, it is /usr/bin/java), there are no alternatives available for this command. To see the full alternatives (including slaves), use the --display option: > sudo update-alternatives --display java java - ...
Find elsewhere
🌐
GitHub
github.com › scylladb › scylladb › issues › 3075
On Debian 8 update-java-alternatives generate multiple errors · Issue #3075 · scylladb/scylladb
December 19, 2017 - $ sudo update-java-alternatives -s java-1.8.0-openjdk-amd64 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 ...
Author   scylladb
🌐
GitHub
github.com › martinruenz › maskfusion › issues › 1
update-alternatives: error: no alternatives for mozilla-javaplugin.so · Issue #1 · martinruenz/maskfusion
December 7, 2018 - Hello ,Firstly , thank you for your contribution about Maskfusion's method and code ! When I build the environment of Maskfusion as the build.sh described and execute the command: sudo update-java-alternatives -s java-1.8.0-openjdk-amd64...
Author   martinruenz
Top answer
1 of 4
74

The trick is to use update-java-alternatives (from the java-common package).

So to go for OpenJDK 6 to 7, I used update-java-alternatives -l to get a list of Java alternatives and then used sudo update-java-alternatives -s java-1.7.0-openjdk-amd64 to the JDK.

NOTE: The command above threw the following errors,

update-alternatives: error: no alternatives for mozilla-javaplugin.so.
update-java-alternatives: plugin alternative does not exist: /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/IcedTeaPlugin.so

This is because the openjdk plugin is not installed by default. To fix run

sudo apt-get install icedtea-7-plugin

and rerun update-java-alternatives.

2 of 4
4

< TL;DR > update-java-alternatives uses the .jinfo file to determine which alternatives to switch across but also expects them to have been configured separately.

Create a new .jinfo file and update-alterntive entries if your downloaded JRE/JDK does not switch over with update-java-alternatives

[Details]

To configure it manually:

  1. Decompress your new jdk alongside the existing jdk in /usr/lib/jvm/

  2. Generate a .jdkname.jinfo file by duplicating another .jinfo file in the folder (or grab one from another Ubuntu install: you are after the template as much as anything else).

    The filename .jdkname.jinfo must match the jdk foldername.

    Modify the content to set the header (names) and the file paths (program entries) to match your new install.

    Remove any lines referring to programs omitted in your version and add lines for new programs in /bin

  3. Generate alternatives for all the programs now in your .jinfo package with this template:

    sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/**jdkname**/bin/java 100
    

    (Several related answers have scripted this from the contents of /bin or you can perform regexp search/replace on your .jinfo file to generate the script commands.)

    Note the 100 is just the priority which is considered when setting the jdk version using the auto flag.

  4. Check the java alternatives and switch to use the JDK.

    update-java-alternatives -l  
    update-java-alternatives -s jdkname  
    

    Note that some JDKs do not include the JRE, so either add it or remove those jinfo entries.

🌐
LinuxVox
linuxvox.com › blog › update-alternatives-warning-etc-alternatives-java-is-dangling
How to Fix update-alternatives: warning: /etc/alternatives/java is dangling on Linux After Removing OpenJDK 7 — linuxvox.com
If no Java versions are found, install one using your package manager. For example, on Debian/Ubuntu: sudo apt update && sudo apt install openjdk-11-jdk # Installs OpenJDK 11 ... If you have existing Java versions (or just installed one), set ...
🌐
TecAdmin
tecadmin.net › linux-update-alternatives-command
Update-alternatives Command: A Comprehensive Guide for Linux Users – TecAdmin
April 26, 2025 - sudo update-alternatives --install ... you encounter an error stating that there are no alternatives for a command, it’s likely that the alternative has not been installed yet....
🌐
Super User
superuser.com › questions › 1576013 › how-to-use-sudo-update-alternative-for-java-installation-on-ubuntu-18-04
How to use sudo update-alternative for java installation on Ubuntu 18.04? - Super User
August 7, 2020 - I am trying to install Oracle JDK on ubuntu 18.04. I am using the command sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-14.0.2/bin/java 1 but this command does nothing. But...