56

I recently updated to Intellij 2021.1. However, whenever I try to run my program, I get:

java: error: release version 17 not supported

I have tried snooping around for other answers, and have found none. It appears my sdk is version 16, if that helps.

Smatt14
  • 581
  • 1
  • 4
  • 5
  • The error message should be clearer. It could say "release version 17 not supported by Maven Runner" or "…not supported by module language level" or "…conflicts with maven property 'maven.compiler.target' or something like that. Incomplete error messages are a pet peeve of mine. – MiguelMunoz Jul 31 '23 at 19:59

20 Answers20

38

There is one more place worth checking -> Java Compiler settings

IntelliJ IDEA Settings

Wojciech Fornal
  • 1,265
  • 11
  • 11
28

I had the same problem. What helped in my case is the following. In IntelliJ IDEA I opened File -> Project structure and then clicked Modules and changed the Language level to 17. Then I was able to run my code without problems.

Project structure window

JustAC0der
  • 2,871
  • 3
  • 32
  • 35
  • Same with me, selected "JDK Default" – Coder Dev May 03 '22 at 13:57
  • 1
    Worked for me. +1 Vote. But this is horrendous. Rebuild should actually rebuild everything. Thanks a lot for sharing it though. – Ajay Kumar Jul 06 '22 at 16:53
  • This answer, is solution to the following error too: java: error: release version 20 not supported too. I set the language level to 17. Installed Jdk by Intellij is 18. – Davoud Nov 13 '22 at 13:45
14
  1. Check that a JDK 17 is available at File -> Project Structure -> Platform Settings -> "SDKS"
    File -> Project Structure -> Platform Settings -> "SDKS"

  2. Select the 17 JDK at File -> Project Structure -> Project Settings -> "Project"
    File -> Project Structure -> Project Settings -> "Project"

  3. File -> Invalidate Caches... -> (leave defaults) -> "Invalidate and Restart"

  4. Do "Build" -> "Rebuild Project"

koppor
  • 19,079
  • 15
  • 119
  • 161
12

This issue happened to me while upgrading to Java 17, I solved it by configuring the new SDK in project structure and invalidate the caches : File --> invalidate caches --> default selection and restart.

Radi
  • 6,548
  • 18
  • 63
  • 91
  • 2
    Along with making sure everything points to the version of the jdk you want to use (all over Intellij), this answer is the secret sauce. – Mike Cheel Jun 03 '22 at 22:37
9

I have faced the same error while trying to use version 16.This is because the new version you are trying to use is unstable.

  1. you have to uninstall the version 17 go to: file -> project structure -> SDKs .delete sdk 17 by right clicking on it and then delete. right click on highlighted version(in your case its 17)

  2. now you have to change project sdk go to: file -> project structure -> project . select the previous version which use to work for you , in my case its 15 java version "15.0.2". set project language level to default (SDK default(15-Text blocks))

    changing project sdk and project language level

  3. the last part is to change the project configuration sdk go to your navigation bar where you debug your project then select edit configurations . select the sdk 16 for your project (in my case its 15) to change the project configuration sdk

edine-noella
  • 109
  • 1
  • 1
7
  1. file => setting => Build,Execution,Deployment => Java Compiler
  2. change Target bytcode version to your current version of project.enter image description here
Mounir bkr
  • 1,069
  • 6
  • 6
4

See this answer for the relevant screenshots. Make sure all the source/target levels are configured correctly in all the dialogs. It may be a typo somewhere and 17 is used instead of 1.7 (Java 7).

Inspect .idea/misc.xml file in the project directory, make sure it specifies the correct versions. See also the language levels specified in *.iml module files and in .idea/compiler.xml file.

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904
4

In my case, I had to change the JAVA_HOME and the Path system environment variable to point to Java 17 (I used Amazon Corretto) as well in addition to updating Language Level and SDK for Project. My modules used inheritedJdk from Project itself. Java Compiler version was also 17.

KnockingHeads
  • 1,569
  • 1
  • 22
  • 42
  • I had the same problem when my JAVA_HOME was pointing to version 11. Intellij still uses this for maven project under the hood dispite what setting i changed in intellij. Took a while to figure this out ;-) – dotnet-provoke Oct 01 '22 at 05:38
  • 1
    `echo $JAVA_HOME` told me this was the case. I forgot I was using jenv. So just did a `jenv local 17` and it's good now. – Andrew Cheong Mar 07 '23 at 14:45
2

In my case, updating .idea/misc.xml didn't help. I was upgrading from Intellij 2020.2 -> Intellij 2020.4 -> Intellij 2020.1.1. Ended up with a reset: File -> Manage IDE Settings -> Restore Default Settings...

2

Your error is likely from IntelliJ attempting to call a Java 17 parser for compliance with Java 17 syntax (regardless of the SDK type) and there is no Java 17 JDK installed to perform the syntax checking with. You have 2 options.

Change 'Language Level' (Project Settings / Project in the Module Settings available from context window - right click - in the project window) to match your current SDK (ignoring possible language conflicts with more recent versions)

Download a Java 17 JDK to perform parsing with. That is in Platform Settings/SDKs in the same context menu, select '+', select 'Download JDK', then download and install a Java 17 version.

Dharman
  • 30,962
  • 25
  • 85
  • 135
1

In order to fix this I had to change the Ant build setting Execution -> Jun under JDK. For some reason the default was JDK 11, everywhere else I has specified JDK 16. Once I set this to JDK 16 the problem went away.

Boulder_on
  • 41
  • 2
1

For similar thing happened when upgrading to java 17. I had it changed everywhere else (suggested by other answers) but in the main maven project .iml file there was still reference to openjdk-16. After manually fixing that to "openjdk-17" it started working well

1

For me these had to match...

  1. File | Project Structure | Project | Project SDK

  2. File | Project Structure | Modules | Language level

  3. IntelliJ Idea | Preferences | Build, Exec... | Build Tools | Maven | Importing | JDK for importer

  4. system.properties (file) java.runtime.version=

  5. pom.xml - <java.version>

twu
  • 11
  • 2
1

This worked for me. I went to Project Settings, clicked on Build, Execution, and Deployment, clicked on Java, clicked on Java Compiler, then changed the Java version (Target bytecode version) to 11.

Kalu Ngozi
  • 11
  • 2
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 03 '23 at 14:14
1

There are two actions to take:

  1. Go to File -> Project structure -> Modules and changed the Language level to 17
  2. Go to IntelliJ IDEA -> Settings -> Build, Execution, Deployment -> Compiler -> Java Compiler. Change your module's Target bytecode version version to 17.
1

The solution that worked for me was to download Java version 17. You can do this by navigating to File - Project Structure - SDKs and clicking the + button under the Classpath Download button

1

I have tried all the steps like changing the "Target bytecode version" and "Project bytecode version" and "project language level" but none got worked out. finally I fixed it by upgrading the JDK version from 1.8 to the latest version jdk-20.

Note: Don't forget to change the JAVA_HOME path post upgrading the JDK :)

enter image description here

Jack Vicky
  • 81
  • 1
  • 5
0

I had this issue when I was using the default Ant run. When I switched the project to maven with the maven-compiler-plugin with java version set this issue went away.

hawkeye
  • 34,745
  • 30
  • 150
  • 304
0

I solved this by lowering language level

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 16 '22 at 06:14
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

cyril
  • 872
  • 6
  • 29