To change the default Java version on Ubuntu, follow these steps:
update-alternatives --list java
java-version-number
with the version number of the Java executable you want to use:sudo update-alternatives --config java
Select the Java version you want to use by typing the corresponding number and pressing Enter.
Verify that the default Java version has been updated by running the following command:
java -version
This should display the version of Java that is currently set as the default.
Note: If you don't have multiple versions of Java installed on your system, you may need to install a different version of Java before you can change the default version. You can install a specific version of Java by using the apt-get
command. For example, to install Java 8, you can run the following command:
sudo apt-get install openjdk-8-jdk
This will install the OpenJDK 8 package and set it as the default Java version.