0

when I type sudo update-alternatives --config java in termainl I get folowing output:-

$ sudo update-alternatives --config java
There are 3 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-9-oracle/bin/java              1091      auto mode
  1            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode
  2            /usr/lib/jvm/java-8-oracle/jre/bin/java          1081      manual mode
  3            /usr/lib/jvm/java-9-oracle/bin/java              1091      manual mode

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

As you can see there are two exact same java paths /usr/lib/jvm/java-9-oracle/bin/java one is on 0th selection and second in on 3rd selection. Why is this so?? why I am not seeing this for openjdk8 or java-8-oracle??

1 Answer 1

1

I believe when you run java --version you will get java 9 but which is your default. Now update-alternatives will present the system with several options for applicable programs and will indicate which is the default choice when not manually selected by the user, hence the auto seen and the two options for java 9.

Excerpt from man update-alternatives:

update-alternatives  creates,  removes, maintains and displays information about the symbolic links comprising
the Debian alternatives system.

It is possible for several programs fulfilling the same or similar functions to be installed on a single  sys‐
   tem  at  the  same  time.   For example, many systems have several text editors installed at once.  This gives
   choice to the users of a system, allowing each to use a different editor, if desired, but makes  it  difficult
   for a program to make a good choice for an editor to invoke if the user has not specified a particular prefer‐
   ence.

Debian's alternatives system aims to solve this problem.  A generic name in the filesystem is  shared  by  all
   files  providing interchangeable functionality.  The alternatives system and the system administrator together
   determine which actual file is referenced by this generic name.  For example, if the text  editors  ed(1)  and
   nvi(1)  are  both installed on the system, the alternatives system will cause the generic name /usr/bin/editor
   to refer to /usr/bin/nvi by default. The system administrator can override this  and  cause  it  to  refer  to
   /usr/bin/ed  instead, and the alternatives system will not alter this setting until explicitly requested to do
   so.

In other words, it says you have three choices for java and that one of those choices will always be used under normal circumstances.

You must log in to answer this question.