DEV Community

Angie Jones
Angie Jones

Posted on

IntelliJ - Error:java: release version 5 not supported

A common error in IntelliJ when attempting to run a new Java maven project is Error:java: release version 5 not supported.

Here are 3 techniques to resolve this. Try them in order. If one doesn't resolve the issue, try the next.

1. Update Java Compiler

  • Go to IntelliJ IDE menu item (or File on Windows) -> Preferences -> Build, Execution, Deployment -> Java Compiler

  • Delete value under Target bytecode version, then click OK

  • Refresh maven

  • Try running again. If problem persists, continue on to number 2 below

2. Update SDK Version

  • Go to File -> Project Structure -> Project Settings -> Project. Make sure you have the correct Java version selected. It should be the same as the one you downloaded

  • Also on this same panel, go to Platform Settings -> SDKs. Make sure you have the correct Java version selected

  • Click OK

  • Refresh maven

  • Try running again. If problem persists, continue on to number 3 below

3. Add property to pom.xml

  • Within IntelliJ, open pom.xml file

  • Add this section before <dependencies> (If your file already has a <properties> section, just add the <maven.compiler...> lines below to that existing section):

   <properties> 
      <maven.compiler.source>1.8</maven.compiler.source> 
      <maven.compiler.target>1.8</maven.compiler.target> 
   </properties>
Enter fullscreen mode Exit fullscreen mode
  • Change the x in 1.8 to your Java version. For example, if you’re using Java 13, change 1.8 to 1.13

  • Refresh maven

  • Try running again

Oldest comments (35)

Collapse
 
jrsofty profile image
Jason Reed

Maven by default always targets JRE 5. You should always configure the correct Java version as you have shown in the pom.xml

Collapse
 
lopitz profile image
Lars Opitz

The proper solution for maven-based projects is to change the target version as shown by Angie in option 3. I added some background on the root cause and provided an additional example for spring boot projects and "plain" java projects here:

Collapse
 
dopplergit profile image
dopplerGit

Yeah I had the same problem, Why don't the ItelliJ just add these things by itself.

Android studio is so nice to work with everything is auto.

Collapse
 
ishwaks profile image
Ishwak Sharda

By default, your "Project bytecode version isn't set in maven project.

It thinks that your current version is 5, so just go to "Project Settings>Build, Execution...>compiler>java compiler" and then change your bytecode version to your current java version.

Have a good day :)

Collapse
 
matthew_c_o profile image
Matthew Ohrenberg

This is what fixed mine. Thank you very much, sir.

Collapse
 
cyalef profile image
Bhavishay Mankani

Thank you so much, it totally worked for me.

Collapse
 
lingzhixu6 profile image
lingzhixu6

Wow works magically!

Collapse
 
voytekpaterek profile image
Greg

The third option worked. Thank you!

Collapse
 
tabletin profile image
Rafael Vidal

Angie solution number 3 worked fine for me!
thanks Angie!

Collapse
 
mfelipebr profile image
Mario Felipe Nogueira de Almeida

A terceira opção funcionou. Obrigado! The 3th option worked. Thanks.

Collapse
 
mobilevisuals profile image
mobilevisuals

It works!

Collapse
 
bharath33 profile image
Bharath

Thanks a lot Angie Jones, this helped me to solve my problem.

Collapse
 
nathanverrilli profile image
nathanverrilli

New to Maven, and this indeed bit me. Changing the targeted release in the POM file un-confused Intellij (per your option 3) -- thank you!

Collapse
 
pradhan41 profile image
pradhan41 • Edited

None of Angie's steps worked for me but setting build plugin in POM file like below worked for me .
"



org.apache.maven.plugins
maven-compiler-plugin
3.8.1

11
11



"

Collapse
 
theiotman profile image
theIOTman

This problem usually happen when you create new project in InteliJ. To solve this problem you can follow this video step by step:
youtu.be/ijhk7eLbizM
Sorry for my bad english.

Collapse
 
gleidecn profile image
gleidecn

Thank you Angie so much!!! I loved your tips, my problem was on the pom.xml

Collapse
 
donegitit profile image
DoneGitIt

Thanks! This works like a charm.