Categories

  • articles

Tags

  • java
  • maven

Quick addion of the things around Java 11 that is required to get your enviroment ready for development. See part one on the Java 11 installation first: Part 1

Update Maven

Getting the latest version of maven is highly recommended here is quick instruction on how to upgarde. apt does not seem to have the latest version.

Check the donwload page of maven for the latest version and copy the url of lates version : Maven Download Page Replace below with your version.

wget https://www-eu.apache.org/dist/maven/maven-3/3.6.0/binaries/apache-maven-3.6.0-bin.tar.gz -P /tmp
sudo tar xf /tmp/apache-maven-*.tar.gz -C /opt
sudo ln -s /opt/apache-maven-3.6.0 /opt/maven

Setup the Enviroment variables:

sudo nano /etc/profile.d/maven.sh

Past following config:

export M2_HOME=/opt/maven
export MAVEN_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}

If you are running multiple version of java is recommend to use the maven config file to set the java home.

nano ~/.mavenrc

Past this content (check you java directory). Also makes it easy to comment out if you want to use Java 8 for other maven project.

JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64
# JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64

Maven pom.xml

It is also recommend using the latest maven compile by setting in pom.xml

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.0</version>
    <configuration>
        <release>11</release>
    </configuration>
</plugin>

“release” is a new config argument for Java 9+. More Info. Can also be set with property maven.compiler.release

Sources