How to switch between Java 8 and 11 on Ubuntu?

I made a few days ago the transition from Windows 7 to Ubuntu 18.04 LTS, and I had some difficulties in the process. Well, let's get to the details.

I installed JDK 11 through the following command:

sudo apt-get install openjdk-11-openjdk

But I need JDK 8 for some college projects. How can I switch between openJDK 8 and 11? In Windows I did modifying the system variable PATH, so I imagine there must be something similar...

Author: Arthur Siqueira, 2019-04-29

1 answers

Just update the java version you want to use. To list all installed versions use the command

update-java-alternatives --list

To update just type the following:

sudo update-java-alternatives --set /caminho/para/versao/java

Where /caminho/para/versao/java can be, for example: /usr/lib/jvm/java-8-openjdk-amd64

 3
Author: Felipe Avelar, 2019-04-29 18:29:24