Compiler Error: Unsupported Release Version 11 in Maven 3.8.0

To download Maven, visit http://maven.apache.org/download.cgi. In Eclipse, go to “Window” and then “Preferences”. From there, select “Maven” and then “Installations”. Add an external installation and provide the path for conf/settings.xml from the external installation in “User Settings”. Ensure that the local repository remains the same as the embedded one. You can review plugin details under “Maven” and then “Installations” in “Preferences”. It’s worth noting that there were a few problems with the embedded installation.

Question:

It’s impossible to utilize the maven-compiler-plugin’s newest version for constructing with Java 11.

pom.xml:


    
        
            org.apache.maven.plugins
            maven-compiler-plugin
            3.8.0
            
                11
            
        
    

when I try to build using Maven:

➜  mvn clean compile
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building service 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ service ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 80 source files to /home/mip/service/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.859 s
[INFO] Finished at: 2018-08-01T11:20:55+01:00
[INFO] Final Memory: 32M/124M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project service: Fatal error compiling: release version 11 not supported -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

These are the tools that I am utilizing – Maven and
Java versions
.

➜  mvn -version
Apache Maven 3.5.2
Maven home: /usr/share/maven
Java version: 10.0.1, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_GB, platform encoding: UTF-8
OS name: "linux", version: "4.15.0-29-generic", arch: "amd64", family:     "unix"
➜  /usr/lib/jvm/java-11-openjdk-amd64/bin/java -version
openjdk version "10.0.1" 2018-04-17
OpenJDK Runtime Environment (build 10.0.1+10-Ubuntu-3ubuntu1)
OpenJDK 64-Bit Server VM (build 10.0.1+10-Ubuntu-3ubuntu1, mixed mode)

Is it possible that the issue is caused by Java 11 presenting itself as “10.0.1”? Making a change to my pom.xml file as shown in

<release>10</release>

results in a successful build, despite the absence of Java 10 on my system.

➜  ~ /usr/lib/jvm/java-11-openjdk-amd64/bin/javac -version
javac 10.0.1 
➜ javac --release 11 SomeClass.java
javac: release version 11 not 
supported Usage: javac  
use --help for a list of possible options

The problem seems to be related to the Ubuntu package with the following MSDT code:

openjdk-11-jdk

.

➜  ~ sudo apt install openjdk-11-jdk
Reading package lists... Done
Building dependency tree       
Reading state information... Done
openjdk-11-jdk is already the newest version (10.0.1+10-3ubuntu1).
0 to upgrade, 0 to newly install, 0 to remove and 2 not to upgrade.



Solution 1:

The requirement is for the

JAVA_HOME

to be configured. I encountered a similar problem and resolving the JDK by setting

JAVA_HOME

proved effective.


Solution 2:


During the creation of a Java project inside a docker container, an error was encountered. It is believed that the error was caused by the installation of Maven. However, switching to the official Maven image as the base for the container resolved the issue.

Specifically, this involved utilizing the subsequent code in my Dockerfile:

FROM maven:3.6.3-jdk-11-slim


After a thorough examination, it became apparent that the key disparity was that the

java-11-openjdk

package was in my possession, whereas I required the

java-11-openjdk-devel

package.


Solution 3:


It appears that you are utilizing Java 9. In order to be constructed with Java 11, kindly attempt the following suggestion:

  1. Set the JAVA_HOME variable to point to the directory where JDK 11 is installed, which should be C:Program FilesJavajdk-11.

  2. To include <code>
    “&lt;properties&gt; &lt;java.version&gt;11&lt;/java.version&gt; &lt;/properties&gt;”
    </code> in your pom.xml, reference ${java.version} where necessary.

  3. Upon entering “mvn -v” into the command line, the output may vary based on the location of your maven and java installations. The output should contain the Maven version, which in this case is 3.6.1 with a specific build ID and timestamp. Additionally, the output should include the location of the Maven home directory and the Java version being used, which is 11.0.6 in this case. The output will also display the default locale, platform encoding, operating system name, version, architecture, and family.

  4. <p>
    Then retry mvn clean install
    </p>

  5. In case you are still unsuccessful, kindly provide us with your pom.xml file, which can help us identify any configuration issues that might be causing the build to fail.


Solution 4:

My experience was due to having a Java 11 JRE instead of a JDK installed. Despite the folder name containing “jdk,” I was mistaken. Upon inspecting the

/bin

directory, I didn’t find an executable for

javac

. As a result, I believe it resorted to using the earlier version of Java, which was the default on the system.

Frequently Asked Questions