Alternatives: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 31: Line 31:
On some occasions, for example Amazon Linux 2, <code>alternatives --set</code> failed:
On some occasions, for example Amazon Linux 2, <code>alternatives --set</code> failed:


<font size=-1>
<font size='70%'>
  alternatives --set java  /usr/lib/jvm/amazon-corretto-8.292.10.1-linux-x64/bin/java
  alternatives --set java  /usr/lib/jvm/amazon-corretto-8.292.10.1-linux-x64/bin/java
  /usr/lib/jvm/amazon-corretto-8.292.10.1-linux-x64/bin/java <font color=red>has not been configured</font> as an alternative for java
  /usr/lib/jvm/amazon-corretto-8.292.10.1-linux-x64/bin/java <font color=red>has not been configured</font> as an alternative for java
</font>
</font>

Revision as of 23:30, 25 June 2021

Internal

Overview

alternatives

Obtain the Alternatives for an Executables

alternatives --display java
alternatives --display java | grep priority

The output contains the "alternatives" - which include the full path of the executable and a priority.

Set an Alternative Interactively

alternatives --config java

Set an Alternative Non-Interactively

The following command seems to work:

alternatives --set java /usr/lib/jvm/java-1.8.0-amazon-corretto/jre/bin/java

The exact path can be obtained with --display. The command is sensitive to the exact absolute path of the "alternative" executable.

On some occasions, for example Amazon Linux 2, alternatives --set failed:

alternatives --set java  /usr/lib/jvm/amazon-corretto-8.292.10.1-linux-x64/bin/java
/usr/lib/jvm/amazon-corretto-8.292.10.1-linux-x64/bin/java has not been configured as an alternative for java