To install Java on Ubuntu 20.04, you can use the following steps:
sudo apt update
sudo apt install default-jdk
This will install the latest version of OpenJDK available in the Ubuntu 20.04 package repository.
Alternatively, you can install a specific version of OpenJDK using the apt-get
command. For example, to install OpenJDK 11, you can use the following command:
sudo apt install openjdk-11-jdk
java -version
This will display the version of Java that is currently set as the default on your system.
If you want to use a different version of Java, you can update the default version using the update-alternatives
command. For example, to set OpenJDK 11 as the default, you can use the following command:
sudo update-alternatives --config java
This will display a list of available Java versions, and you can select the desired version by entering its corresponding number.