title: Maven is using wrong java version
body: <p>I am trying to build a maven project on centOS 8. I want maven to use Java version 15. When I run <code>mvn package</code> I get the following error:</p>
  <pre><code>Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile 
  (default-compile) on project systembrett-backend: Fatal error compiling: invalid target release: 15 -&gt; [Help 1]
  </code></pre>
  <p>So I suspect that maven is using the wrong Java version, because when i do <code>mvn package -X</code> for debug logs it start with:</p>
  <pre><code>Apache Maven 3.5.4 (Red Hat 3.5.4-5)
  Maven home: /usr/share/maven
  Java version: 1.8.0_275, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.275.b01-1.el8_3.x86_64/jre
  Default locale: en_US, platform encoding: UTF-8
  OS name: &quot;linux&quot;, version: &quot;4.18.0-240.1.1.el8_3.x86_64&quot;, arch: &quot;amd64&quot;, family: &quot;unix&quot;
  </code></pre>
  <p>so it looks like, maven is using Java version 1.8.
  But <code>mvn -version</code> says:</p>
  <pre><code>Apache Maven 3.5.4 (Red Hat 3.5.4-5)
  Maven home: /usr/share/maven
  Java version: 15.0.2, vendor: AdoptOpenJDK, runtime: /opt/jdk-15.0.2+7
  Default locale: en_US, platform encoding: UTF-8
  OS name: &quot;linux&quot;, version: &quot;4.18.0-240.1.1.el8_3.x86_64&quot;, arch: &quot;amd64&quot;, family: &quot;unix&quot;
  </code></pre>
  <p><code>JAVA_HOME</code> is <code>/opt/jdk-15.0.2+7</code> and <code>PATH</code> is <code>/opt/jdk-15.0.2+7/bin:/home/username/.local/bin:/home/username/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin</code>.</p>
  <p>I thought maven is choosing the java version by checking <code>JAVA_HOME</code>, but apparently it is using an other version for the build. Does anyone know how to tell maven the correct version?
  Thanks!</p>