TLDR
On some Linux systems (RedHat/CentOS based), I have found the UNIX alternatives program being used to manage different versions of java. One of my systems is Ubuntu 20.04, and the alternatives program doesn't exist.
My question is can I use the alternatives program with Ubuntu 20.04?
If so, how do I install it? I tried installing as shown below and it couldn't be found.
sudo apt install alternatives
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package alternatives
NOTE: a similar name sudo apt install galternatives
(a GUI version of alternatives?) did install so I'm looking at that. It might work well enough.
A related question is
(Q) Can I run the alternatives program on any version of Linux or does it only work with a particular Linux package manager? Previously, I used it with CentOSs yum install
command.
How does Alternatives work?
See this article https://www.redhat.com/sysadmin/alternatives-command. I'll include examples described in it so this question stands alone (if that link stops working):
After alternatives is installed I should be able to:
(1) Install multiple versions of applications. As long as each version is installed into a different directories then I can use alternatives.
(2) Configure the alternatives program to know how where different versions of your app are installed.
In this case one is in /opt/em-legacy/em2
and the other is in /usr/local/bin/nem
. I'll give it the name uemacs, and tell alternatives to make it available in /usr/bin/em
so I don't need to change my path to run it.
$ sudo alternatives --install /usr/bin/em uemacs /opt/em-legacy/em2 1
$ sudo alternatives --install /usr/bin/em uemacs /usr/local/bin/nem 99
(3) Tell alternatives which version of the app you want to use. This is done using the alternatives --config
command as shown below.
$ sudo alternatives --config uemacs
[sudo] password for seth:
There are 2 programs which provide 'uemacs'.
Selection Command
-----------------------------------------------
*+ 1 /usr/local/bin/nem
2 /opt/em-legacy/em2
There is more to it that is explained in the referenced article.
Background Information for my question
For years, I've managed my Java installs manually and would unzip/untar the Java package and when it needed to be updated repeat the unzip/untar into a new directory and manage symlinks to point to the version I was most predominately using.
Enter cloud... I'm so freakin tired of installing Java manually, I've got to find another (easier) way. Alternatives seems to be a good solution.