Alternatives: Difference between revisions
Jump to navigation
Jump to search
(Created page with "=Internal= * Linux =Overview= <syntaxhighlight lang='bash'> alternatives </syntaxhighlight>") |
|||
(12 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
=Internal= | =Internal= | ||
* [[Linux#Commands|Linux]] | * [[Linux#Commands|Linux]] | ||
* [[Java on Linux]] | |||
=Overview= | =Overview= | ||
Line 6: | Line 7: | ||
<syntaxhighlight lang='bash'> | <syntaxhighlight lang='bash'> | ||
alternatives | alternatives | ||
</syntaxhighlight> | |||
=Obtain the Alternatives for an Executables= | |||
<syntaxhighlight lang='bash'> | |||
alternatives --display java | |||
alternatives --display java | grep priority | |||
</syntaxhighlight> | |||
The output contains the "alternatives" - which include the full path of the executable and a priority. | |||
=Set an Alternative Interactively= | |||
<syntaxhighlight lang='bash'> | |||
alternatives --config java | |||
</syntaxhighlight> | |||
=Set an Alternative Non-Interactively= | |||
One way of setting an alternative java installation is with <code>--set</code>. | |||
<syntaxhighlight lang='bash'> | |||
alternatives --set java /usr/lib/jvm/java-1.8.0-amazon-corretto/jre/bin/java | |||
</syntaxhighlight> | |||
The exact path can be obtained with [[#Obtain_the_Alternatives_for_an_Executables|--display]]. The command is sensitive to the exact absolute path of the "alternative" executable. | |||
On occasions, <code>alternatives --set</code> fails: | |||
<font size='-1'> | |||
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 | |||
</font> | |||
In that situation, an alternative installation method is: | |||
<syntaxhighlight lang='bash'> | |||
cd /usr/lib/jvm/ | |||
tar tfvz amazon-corretto-8-x64-linux-jdk.tar.gz | |||
alternatives --install /usr/bin/java java /usr/lib/jvm/amazon-corretto-8.292.10.1-linux-x64/bin/java 10 | |||
</syntaxhighlight> | </syntaxhighlight> |
Latest revision as of 23:41, 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
One way of setting an alternative java installation is with --set
.
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 occasions, alternatives --set
fails:
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
In that situation, an alternative installation method is:
cd /usr/lib/jvm/
tar tfvz amazon-corretto-8-x64-linux-jdk.tar.gz
alternatives --install /usr/bin/java java /usr/lib/jvm/amazon-corretto-8.292.10.1-linux-x64/bin/java 10