IntelliJ: Error: java: release version 10 not supported
Asked Answered
V

18

87

In IntelliJ, I'm getting this strange error message when I try to build from the build menu

Error: java: release version 10 not supported

I don't understand this, since in Project Structure, I have these settings set:

Project SDK: 9.0
Project Language Level: SDK Default
Module Language Level: Project Default (both modules)

In my pom.xml files, I have these properties set in both modules:

<maven.compiler.source>9</maven.compiler.source>
<maven.compiler.target>9</maven.compiler.target>

I have no idea why it's trying to use JDK 10 for anything, but I still get that message.

I'd be happy to use JDK 10, but my project doesn't work in that version, so I'm going back to see which versions it works in. I have SDKs installed for version 1.4 through 10.

I've also tried building using JDK 1.8, but I get a slightly different error message:

Error: java: invalid target release: 10

I've found that I can build from the command line using JDK 9, but I need to build from my IDE.

Can anyone tell me how to build my project using JDK 1.9 or 1.8?

Vlaminck answered 13/10, 2018 at 1:32 Comment(2)
By the way, there is JDK 11 LTS... Be free to remove Java 9 and 10, and migrate to Java 11Obadiah
The answer is here. it is related to maven default compiler version, that needs to changeNavarre
V
13

I just figured it out. I also needed to adjust the version in the maven-compiler-plugin. I'm using version 3.8.0. I needed to change this value:

<release>10</release>

Here's where I found it:

<build>
  <plugins>
    <plugin>
      <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.0</version>
        <configuration>
            <release>10</release> <!-- This was the problem. -->
        </configuration>
        ...
Vlaminck answered 13/10, 2018 at 1:40 Comment(2)
could you post more of the config please? I want to see where that fits in.Duma
@Duma <build> tag is placed under main <project> one.Lexis
M
186

I got a similar error but did not use Maven.

It's resolved by updating the IntelliJ configuration:

  • File -> Settings-> Build, Execution, Development -> Compiler -> Java Compiler
  • update Project bytecode version to 8

enter image description here

Mcwhirter answered 2/3, 2019 at 22:41 Comment(2)
Also check File -> project structure and then take a look at Project and Modules tab. Set language level to 11 or whatever you're using. Note! For every module it is possible to set the language level. So check all of them in de Modules tab!Host
my module's target bytecode version is 13. but I have to put project bytecode version on 8, why is it like this? can you explain?Slat
S
36

I had similar issue except that the error was "release version 5 not supported. " I tried all of the above and other proposed solutions but nothing worked, except putting following xml into the pom.xml file:

<properties>
    <maven.compiler.release>11</maven.compiler.release>
</properties>

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

Code comes from: Maven in 5 Minutes | Apache Maven Project

After putting this code in pom.xml, make sure to Import Changes or Enable Auto-Import for the Maven project:

Intellij popup box

Scirrhous answered 14/11, 2019 at 18:16 Comment(0)
T
26

The most upvoted answer really helped me. However, for me the problem wasn't the Project bytecode version. Instead, my Maven module was marked with Target bytecode version 1.5, see picture below.

Just clicking the row and removing it fixed the problem:

  • File -> Settings-> Build, Execution, Development -> Compiler -> Java Compiler
  • Delete any Per-module bytecode versions in the list, which override the project bytecode version.

Per-module bytecode version

Triphthong answered 29/9, 2019 at 6:38 Comment(1)
This one didn't work for me at the time, but I ran into a similar problem yesterday, and this one was the fix. Thanks.Vlaminck
Q
16

Probably your IntelliJ IDEA previously used Java 8. Starting from java 9 Java, instead of having 2 parts, jdk and jre, Java has only one, the jdk. I have got the same error message when I switched from java 8 to java 11. So you have to switch the IntelliJ IDEA to the new Java version.

Open the Project Structure(Ctrl+Shift+Alt+S)

enter image description here

Alternatively, from the IntelliJ IDEA menu: File -> Project Structure -> Project

Define the new jdk. Recompile the project.

This has worked for me.

Quinta answered 16/3, 2019 at 23:6 Comment(0)
V
13

I just figured it out. I also needed to adjust the version in the maven-compiler-plugin. I'm using version 3.8.0. I needed to change this value:

<release>10</release>

Here's where I found it:

<build>
  <plugins>
    <plugin>
      <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.0</version>
        <configuration>
            <release>10</release> <!-- This was the problem. -->
        </configuration>
        ...
Vlaminck answered 13/10, 2018 at 1:40 Comment(2)
could you post more of the config please? I want to see where that fits in.Duma
@Duma <build> tag is placed under main <project> one.Lexis
E
5

Resolved issue in File -> Project Strucuture.

Changed Project Language Level to 11.

IntelliJ Issue:

image

Edie answered 15/9, 2020 at 4:46 Comment(0)
A
4

I solved this by going to Maven settings;

Step 1. either going through;

  • monkey wrench icon in maven (jump to step 2)
  • File - Settings or Ctrl+Alt+S

Step 2. Go to Build, Execution, Deployment - Maven - Importing: JDK for importer (at the bottom)

Adele answered 3/1, 2020 at 12:44 Comment(0)
B
3

At first, Put this code in your pom.xml

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>Current Latest Version of Maven e.g. 3.8.1</version>
            <configuration>
                <target>Java Version installed in your system e.g. 13</target>
                <source>Java Version installed in your system e.g. 13</source>
                <release>Java Version installed in your system e.g. 13</release>
            </configuration>
        </plugin>
    </plugins>
</build>

And Also Go to File> Settings > Build, Execution, Deployment > Compiler> Java Compiler and change "Project bytecode version" to Java Version installed in your system e.g. 13

Barclay answered 8/2, 2020 at 19:30 Comment(0)
P
2

I got this message Java error version 12 is not supported. and I am using 11.

How did I managed to solve this issue? Go to File --> Project Structure --> Project and Change the Project Language Level to the version that you have and click and apply.

Puduns answered 21/10, 2019 at 8:47 Comment(0)
I
2

file -> project structure -> project -> set the project language level same as of your SDK.

enter image description here

Israelitish answered 9/9, 2021 at 4:55 Comment(0)
D
1

For someone just update their maven file in properties section, please make sure if you click the refresh on the IDE maven tool in order to trigger the prop settings.

Step 1.

<properties>
    <maven.compiler.source>1.5</maven.compiler.source>
    <maven.compiler.target>1.5</maven.compiler.target>
</properties>

Step 2. (very important!!!)

Click "refresh" icon on IntelliJ Maven tool bar.

Dextrogyrate answered 13/11, 2019 at 23:30 Comment(0)
L
1

One more option you can try, go to Maven and check which JRE version it is fetching.I solved my issue by fixing it. I had HDK 14 but it was considering 11.

Leucopoiesis answered 6/12, 2020 at 7:25 Comment(0)
G
1

This issue is normally pops up with newly setup projects because of the .idea package.

The . idea folder (hidden on OS X) in the solution root contains IntelliJ's project specific settings files. These include per-project details such as VCS mapping and run and debug configurations, as well as per-user details, such as currently open files, navigation history and currently selected configurations.

  • Delete the .idea package and restart the IDE.

Most Probably Ur building issue is gone away :)

Gingerly answered 1/3, 2021 at 12:37 Comment(0)
F
0

putting below code in pom.xml works.

<maven.compiler.release>11</maven.compiler.release>

Forgiven answered 10/12, 2019 at 16:7 Comment(1)
Where did you put this?Vlaminck
F
0

For me in IntelliJ, I just went to file then project structure then I chose different SDK version rather the one shown in the error message and the error has gone :)

Fortunato answered 3/7, 2020 at 15:35 Comment(0)
V
0

You have to upgrade current sdk version to newest one. Project Structure -> Project -> SDK -> Add SDK -> Download JDK

Vyner answered 23/8, 2022 at 14:0 Comment(0)
S
0

for me i spend really lot of time all was configured correctly, but strangely, the pom.xml was ignored, so right click on pom file => maven => unignore project (on all projects and module)

enter image description here

Swinish answered 19/10, 2022 at 5:8 Comment(0)
O
0

I my case I download new project, add it to IDEA and it was not add like Maven project. So I just right click on pom.xml and Add as Maven Project.

enter image description here

Oxy answered 8/2, 2023 at 12:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.