Error:java: invalid source release: 8 in Intellij. What does it mean?
Im trying to compile some code in I’m using Intellij Ultimate 13.1.4, but I get the following error and I have no idea what it means:
17 Answers 17
I had the same issue when «downgrading» a project from Java 8 to Java 6. The reason was that it was not changed at all places in IntelliJ.
In IntelliJ 13.1.4 I had to change Java and SDK version on the following places not to get this error:
The last bullet was the one that was not updated in my case. Once I changed this, the error disappeared.
Change in pom.xml 1.6 to 1.8
If you are using Gradle as a build tool and you get this error when executing a Gradle task i.e TomcatRun take a look to my other answer to the same question
Andreas Lundgren’s answer worked and I was able to compile and run my app.
However, when I tried to run the project’s associated JUnit tests I received the same error. Running
from Windows command prompt showed that gradle was still picking up the incorrect jdk. To fix it I had to set the JAVA_HOME environment variable to point to the correct jdk and restart IntelliJ.
I face this error Error:java: invalid source release: 1.8 in IntelliJ Idea 2017.2.6 because I upgraded the dependency version Maven pom file, which(dependency) were supposed to build for JDK 1.8 application and I were building my application on and with maven compiler source and target JDK 1.7.
Hence I again downgrade the dependency version to earlier one in Maven pom, and the error gone after project Rebuild Module ‘xyz_project’.
For Grails users, apply these declarations in your BuildConfig.groovy file:
You need to click to the project Open Module Settings and change the path of your JDK, if in the file POM you use jdk 1.8, configure jdk 1.8 with correct path.
I add one more path unmentioned in this answer https://stackoverflow.com/a/26009627/4609353
but very important is Edit Configurations
In there, as shown in below figure, you need to change the «Target bytecode version». Although, I changed it to 8 (since I needed to downgrade to Java 8), it was giving the same error, over and over. Therefore, try to remove the existing entry (in this table) and add it again. This worked for me.
On the other hand, clean the project and try to run again.
I had the same issue the solution for me was to change my java version in the pom.xml file.
I changed it from 11 to 8.
Lots of good answers. For those using the (almost) latest version of Intellij, at the time of writing, what can be said, is that the project JDK can be at a higher level, than that of the module. In fact without it, Maven will have to be rolled back to an older version. Therefore with the following version of Intellij:
One should not change the project level JDK and therefore be able to leverage the Maven or Gradle settings when building, but when running Maven or running Gradle using a more modern version of the JDK. If you lower your project level JDK from say JKD8 to JDK6, Maven or Gradle will not run.
Keeping your module at a lower level JDK-wise will enable you to build it to that version, if you use the Module rebuild or build options; using the menu options for rebuilding the project will complain wit «Invalid source release:8. «.




















