First check the default-jdk
package, good chance it already provide you an OpenJDK >= 11
.
ref: https://packages.ubuntu.com/search?keywords=default-jdk&searchon=names&suite=all§ion=all
So starting from Ubuntu 18.04 LTS it should be ok.
sudo apt update -qq
sudo apt install -yq default-jdk
note: don't forget to set JAVA_HOME
export JAVA_HOME=/usr/lib/jvm/default-java
mvn -version
For Ubuntu 16.04 LTS, only openjdk-8-jdk
is provided in the official repos so you need to find it in a ppa:
sudo add-apt-repository -y ppa:openjdk-r/ppa
sudo apt update -qq
sudo apt install -yq openjdk-11-jdk
note: don't forget to set JAVA_HOME
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
mvn -version