2020. március 9.

Update Java version with AdoptOpenJDK

1. Install the JDK version you want with apt-get
(Steps copied from the linked source)

Import the official AdoptOpenJDK GPG key by running the following command:
wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -

Import the AdoptOpenJDK DEB repository by running the following command:
sudo add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/

Refresh your package list:
sudo apt-get update

Install your chosen AdoptOpenJDK package. For example, to install OpenJDK 8 with the HotSpot VM, run:
sudo apt-get install <adoptopenjdk-8-hotspot>

2. update alternatives:

List alternatives for java:
~$ update-alternatives --list java

Check the java version of the alternative you would like to set:
~$ /usr/lib/jvm/adoptopenjdk-11-hotspot-amd64/bin/java --version
openjdk 11.0.6 2020-01-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.6+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.6+10, mixed mode)

Set the chosen version as the default:
~$ sudo update-alternatives --set java /usr/lib/jvm/adoptopenjdk-11-hotspot-amd64/bin/java

update environmetal variables
For me, there is a maven.sh in /etc/profile.d that sets the env vars required for maven.
~$ sudo gedit /etc/profile.d/maven.sh
Update the JAVA_HOME path here. (in my case to /usr/lib/jvm/adoptopenjdk-11-hotspot-amd64/)

Nincsenek megjegyzések: