Managing different versions of a software in Ubuntu is made easy by update-alternatives. For example, assume having different versions of eclipse in Ubuntu.
The eclipse can be installed from the tar balls available from eclipse download page. Juno Download page. Indigo Download Page.
Move the downloaded the tar balls to /opt and unzip them. (/opt - just a directory for optional packages)
The launcher executable (eclipse.exe) for the installed versions of eclipse would be in the respective install folder. I.e., In our case there will be a launcher executable (eclipse.exe) inside "/opt/eclipse_juno/" and "/opt/eclipse_indigo".
Now to manage the launch of these two versions of eclipse, we use the "update-alternatives" as shown below.
Now to choose between versions, use "update-alternatives --config".
By giving the selection number, the desired version shall be made set for launching.
Now we see the "update-alternatives --install" in detail. Consider the following command we issued above.
Here the number '20' is the priority for the version of the launcher we configure for alternatives. Higher the number higher the priority.
'/opt/eclipse_juno/eclipse' is the launcher we configure for alternatives.
'eclipse' is a symbolic link to be created in /etc/alternatives/. This symbolic link will point to the launcher we configure. Here it will be '/opt/eclipse_juno/eclipse'.
'/usr/bin/eclipse' is a symbolic link to '/etc/alternatives/eclipse'.
How it works?
'/usr/bin/eclipse' will always link to '/etc/alternatives/eclipse'. And '/etc/alternatives/eclipse' will change its link to the launcher we configure through "update-alternatives --config".
The eclipse can be installed from the tar balls available from eclipse download page. Juno Download page. Indigo Download Page.
Move the downloaded the tar balls to /opt and unzip them. (/opt - just a directory for optional packages)
$cd /opt /opt$sudo mv ~/Downloads/eclipse-cpp-juno-SR2-linux-gtk-x86_64.tar.gz . /opt$sudo tar xzvf eclipse-cpp-juno-SR2-linux-gtk-x86_64.tar.gz /opt$sudo mv eclipse eclipse_juno /opt$sudo mv ~/Downloads/eclipse-cpp-indigo-SR2-incubation-linux-gtk-x86_64.tar.gz . /opt$sudo tar xzvf eclipse-cpp-indigo-SR2-incubation-linux-gtk-x86_64.tar.gz /opt$sudo mv eclipse eclipse_indigo
The launcher executable (eclipse.exe) for the installed versions of eclipse would be in the respective install folder. I.e., In our case there will be a launcher executable (eclipse.exe) inside "/opt/eclipse_juno/" and "/opt/eclipse_indigo".
Now to manage the launch of these two versions of eclipse, we use the "update-alternatives" as shown below.
$sudo update-alternatives --install /usr/bin/eclipse eclipse /opt/eclipse_juno/eclipse 20 $sudo update-alternatives --install /usr/bin/eclipse eclipse /opt/eclipse_indigo/eclipse 10
Now to choose between versions, use "update-alternatives --config".
$ sudo update-alternatives --config eclipse There are 2 choices for the alternative eclipse (providing /usr/bin/eclipse). Selection Path Priority Status ------------------------------------------------------------ * 0 /opt/eclipse_juno/eclipse 20 auto mode 1 /opt/eclipse_indigo/eclipse 10 manual mode 2 /opt/eclipse_juno/eclipse 20 manual mode Press enter to keep the current choice[*], or type selection number:
By giving the selection number, the desired version shall be made set for launching.
Now we see the "update-alternatives --install" in detail. Consider the following command we issued above.
$sudo update-alternatives --install /usr/bin/eclipse eclipse /opt/eclipse_juno/eclipse 20
Here the number '20' is the priority for the version of the launcher we configure for alternatives. Higher the number higher the priority.
'/opt/eclipse_juno/eclipse' is the launcher we configure for alternatives.
'eclipse' is a symbolic link to be created in /etc/alternatives/. This symbolic link will point to the launcher we configure. Here it will be '/opt/eclipse_juno/eclipse'.
'/usr/bin/eclipse' is a symbolic link to '/etc/alternatives/eclipse'.
How it works?
'/usr/bin/eclipse' will always link to '/etc/alternatives/eclipse'. And '/etc/alternatives/eclipse' will change its link to the launcher we configure through "update-alternatives --config".