How to tell compiler to use openjdk 11 via pom.xml

R K picture R K · Jun 18, 2019 · Viewed 10.2k times · Source

How to configure OpenJDK 11 in pom file.

<properties>
  <maven.compiler.plugin.version>3.8.0</maven.compiler.plugin.version>
  <maven.compiler.target>11</maven.compiler.target>
  <maven.compiler.source>11</maven.compiler.source>
</properties>

Answer

Piotr Wilkin picture Piotr Wilkin · Jun 18, 2019

The problem is probably in the version of Java you're using to run Maven. See the discussion here:

Unable to compile simple Java 10 / Java 11 project with Maven

If you want to make Maven recognize a target release of 10 or 11, you have to first run Maven with Java 11. Check that the Java that Maven is using is correct by doing mvn --version.