IntelliJ: Error: java: release version 10 not supported

陌路散爱 提交于 2020-01-01 01:01:29

问题


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 JDK10, 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? Thanks.


回答1:


I got a similar error but did not use Maven.

Solved it by updating the IntelliJ configuration:

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




回答2:


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.




回答3:


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)

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

Define the new jdk. Recompile the project.

This has worked for me.




回答4:


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: https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html

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




回答5:


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>
        ...



回答6:


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.




回答7:


putting below code in pom.xml works.

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




回答8:


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.



来源:https://stackoverflow.com/questions/52788743/intellij-error-java-release-version-10-not-supported

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!