ubuntu change java version

htt‮ww//:sp‬w.lautturi.com
ubuntu change java version

To change the default Java version on Ubuntu, follow these steps:

  1. List the available Java versions by running the following command:
update-alternatives --list java
  1. Choose the Java version you want to use as the default by running the following command, replacing java-version-number with the version number of the Java executable you want to use:
sudo update-alternatives --config java
  1. Select the Java version you want to use by typing the corresponding number and pressing Enter.

  2. 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.

Created Time:2017-10-17 22:51:24  Author:lautturi