What is the usual way of installing a different version of a program on Ubuntu?
1 Answer
Some programs allow more than one version to be installed at the same time. Some examples includes php
, python
, java
, etc.
From the Software Center or the commandline, specify the version you want to install.
To install the default version of the program (openjdk) in this case run:
$ sudo apt install openjdk
You can use apt
search option to check the available version from your installed repository with this command (among other variations). I'm including the command and the output in this example:
$ apt search openjdk | egrep ^open.*jdk/
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
openjdk-6-jdk/lucid 6b18-1.8-0ubuntu1 amd64
openjdk-8-jdk/xenial-updates,xenial-security,now 8u162-b12-0ubuntu0.16.04.2 amd64 [installed]
openjdk-9-jdk/xenial,now 9~b114-0ubuntu1 amd64 [installed]
ljames@ubunzeus:~$
To install openjdk version 8, I would run this command (as an example):
$ sudo apt install openjdk-8-jdk
In short, run the install as normal and include the version of the application as part of the install command.
-
1@N0rbert That is the output of the command. Did you test the command on your computer? The output is showing the versions of openjdk-6-jdk that is installed on my computer. I don't recall ever specifying an openjdk version 6 for install, but it has been a number of years since I performed a clean OS installation. In this case, the output may help to demonstrate how apt automatically maintains the different dependency packages when facilitating multiple version installs. Apr 14, 2018 at 14:33
-
By the way, I have never performed the (apparent) complicated commandlines of the duplicated answer. I'm sure that's because I have never had desire, or need to change to a different version. I always use the current default version unless there's need to install an additional version for a specific task. This is when both versions are in the repository being maintained without conflicting depencies that would be require addressing. Apr 14, 2018 at 14:38
-
-
I accepted your arguments, so we can remove the comments of conversation.– N0rbertApr 14, 2018 at 14:52
sudo apt install package=version
for examplesudo apt install grub-efi-amd64=2.02~beta3-4ubuntu7.2