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. «.
Решение ошибки «invalid target release»
Ошибка «invalid target release» возникает при попытке компилятором Java скомпилировать исходные файлы с неизвестной для него версией Java. В подавляющем большинстве случаев ошибка возникает оттого, что у вас в системе установлена и запускается Java более старой версии, чем та версия Java, которая требуется для компиляции исходных файлов.
Случаи, в которые вы можете натолкнуться на ошибку «Invalid target release»:
Maven error — Fatal error compiling: invalid target release
Вы хотите собрать мавеновский проект, в pom.xml у вас указана более новая версия Java, а в системе установлена более старая версия:
В данном случае в системе установлена JDK 8, а в pom.xml указана Java 12.
Решение проблемы
В данном случае вам нужно либо обновить свой JDK до более нового, либо понизить требуемую версию в файле pom.xml до той, что у вас установлена в системе.
Ошибка «Invalid target release» при сборке в IDE
В операционной системе у вас установлена JDK 8 и в настройках Idea подключена именно эта версия. Но в настройках проекта Idea или в файле pom.xml указана версия JDK 12 (или более новая).
В этом случае, при попытке собрать проект, вы увидите лишь ошибку о неправильной версии:
Решение проблемы
Первый вариант решения проблемы это установить более новую версию JDK и указать её в настройках IntelliJ Idea
Ошибка «Invalid target release» в компиляторе
Решение проблемы
Сначала проверьте версию компилятора:
Если версия компилятора ниже запрашиваемой версии, вам нужно либо передавать в опции компилятора более низкую версию, либо обновить JDK.
Ошибка «Invalid target release» при указании несуществующей версии Java
Вполне возможен вариант, при котором у вас в скрипте сборки проекта указана несуществующая версия Java. Вам лишь нужно удостовериться, что вы указали корректную версию Java.
I tried to following this answer. I changed File> Build,Execution,Deployment> Java Compiler> Project bytecode version: 1.8. However, I can’t change the Module language level and Project language level to 1.8 because there’s not option for that. I still get the same error below.
Error
Code
15 Answers 15
Just change it to 8 (or whatever you need) and you’re set to go.
Also, check the same Language Level settings mentioned above, under Project Settings > Project
Sometimes the problem occurs because of the incorrect version of the project bytecode.
I have had the same problem. There is an answer:
Got it! Now u have Java 9!
You should to set the JAVA SDK and appropriate language level in the project settings. Click to enlarge.
Since we started working with GRADLE,
I am getting this ERROR most of the time and Solution is Change Gradle JVM to XX
I was having this issue while running a SpringBoot project (Maven)
In my POM file I changed the java version from 11 to 8 and it worked:
Make sure to Load maven changes else the change won’t reflect.
When using maven project.
if you have jdk 8 installed in your machine, change java.version property from 9 to 8
I’ve just had a similar issue. The project had opened using Java 9 but even after all the modules and project were set back to 1.8, I was still getting the error.
I needed to force Gradle to refresh the project and then everything ran as expected.
Gradle I had the same issue and changing all the settings given in the earlier solutions made no difference. Than I went to the build.gradle and found this line and deleted it.
Alternatively via Project Settings:
Depending on how your build is set up, this may be the way to go.
For anyone struggling with this issue who tried DeanM’s solution but to no avail, there’s something else worth checking, which is the version of the JDK you have configured for your project. What I’m trying to say is that if you have configured JDK 8u191 (for example) for your project, but have the language level set to anything higher than 8, you’re gonna get this error.
In this case, it’s probably better to ask whoever’s in charge of the project, which version of the JDK would be preferable to compile the sources.
So, I Just change it to 8. Still my issue didn’t got resolve.
Java: Error: Invalid source release: 16
I have encountered this problem to tell this error in learning Spring MVC.
The JDK 16 is used when creating a project, but Tomcat looks like and JDK16 is not very compatible.
So I changed the project’s version of this headache pop-up window. 
At that time, just simply modified this JDK version.
Then still report an error 
The first time I perfectly solved this problem, but I still report an error.
At that time, there was a small word that said the JDK version is set from Maven.
Then open the Maven
Modify it into 8 to solve problems
Solution from a Spring beginner, if there is a better solution, welcome to comment below
Intelligent Recommendation
Resolve Error: java: invalid source release: 11
Need to pay attention to three places: 1. Click on project structure Enter: to be consistent; 2. Also in the above directory to be consistent; 3. Configure java compilation and open setting Or click t.
IDEA: Error: java: Invalid source release: 9
IDEA: Error: java: Invalid source release: 9 Welcome to Markdown editor Check whether the jdk versions in several places are consistent: It is recommended to use them all here: 8-Lambdas,type annotati.
Error java invalid source release version 11
Error when compiling local idea: Error: java: invalid source release: 11 There are three causes and solutions for this problem: Problem 1: IDEA setting error: Solution: Change the version here to be t.
Idea: Error: java: Invalid source release: 10
«error: invalid source release: 14» when running a build #12803
Comments
nlisker commented Apr 14, 2020
Expected Behavior
Build task should complete successfully.
Current Behavior
Build task throws an error with the following stack trace:
ljacomet commented Apr 14, 2020
Can you provide a simple reproducer?
With a basic project and the changes you highlighted, I cannot reproduce this issue.
melix commented Apr 15, 2020
This is an error from the Java compiler itself. It basically means you’re not running Gradle with JDK 14 as you expect. A build scan would confirm.
melix commented Apr 15, 2020
Sorry I missed you already shared a scan. Can you just check you don’t also set javaHome or executable on the java compile tasks to a different JDK?
nlisker commented Apr 15, 2020
Actually, the environment variable JAVA_HOME does point to a different JDK because I need it for non-gradle projects, and the gradle.properties file is the one that points to 14. I thought that this files takes precedence over the env. variable. Are you suggesting that somewhere withing the build file it tries to use the variable instead of the version specified in the properties file?
nlisker commented Apr 16, 2020
That appears to have been the issue.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.

































