Error:java: invalid source release: 8 in Intellij. What does it mean?
Solution 1
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:
- File -> Project Structure -> Project Settings
- File -> Project Structure -> Module Settings -> Tab: Sources: Language Level
- File -> Project Structure -> Module Settings -> Tab: Dependencies: Module SDK
- File -> Settings -> Compiler -> Java Compiler -> Target bytecode version
The last bullet was the one that was not updated in my case. Once I changed this, the error disappeared.
Solution 2
Check your pom.xml
first (if you have one)
Check your module's JDK
dependancy. Make sure that it is 1.8
To do this,go to Project Structure -> SDK's
Add the path to where you have stored 1.8 (jdk1.8.0_45.jdk
in my case)
Apply the changes
Now, go to Project Structure ->Modules
Change the Module SDK to 1.8
Apply the changes
Voila! You're done
Solution 3
Change in pom.xml
1.6
to 1.8
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
Solution 4
For Gradle users having this issues, if nothing above helps this is what solved my problem - apply this declarations in your build.gradle files:
targetCompatibility = 1.6 //or 1.7;1.8 and so on
sourceCompatibility = 1.6 //or 1.7;1.8 and so on
Problem solved!
Solution 5
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
David says Reinstate Monica
https://meta.stackexchange.com/questions/333965/firing-mods-and-forced-relicensing-is-stack-exchange-still-interested-in-cooper?noredirect=1&lq=1 https://meta.stackexchange.com/questions/336024/how-can-we-put-pressure-on-stack-exchange-inc-without-damaging-the-community#comment1110223_336024 https://meta.stackexchange.com/questions/336526/stack-overflow-is-doing-me-ongoing-harm-its-time-to-fix-it Please help in saving StackOverflow!
Updated on January 21, 2022Comments
-
David says Reinstate Monica over 2 years
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:
Information:Using javac 1.7.0_55 to compile java sources Information:java: Errors occurred while compiling module 'Example' Information:Compilation completed with 1 error and 0 warnings in 3 sec Information:1 error Information:0 warnings Error:java: invalid source release: 8
My guess is that its something related to Java 8 vs Java 7, but I have no idea what specifically. I've tried to Google around for this message, but they either talk about
javac
ortarget release
, so it doesn't exactly seem to apply. -
bitoiu about 9 yearsthe one killing me was this one:
File -> Settings -> Compiler -> Java Compiler -> Target bytecode version
. Thanks. -
Emil over 8 yearsI was running into this issue as well, but none of the above worked. I had to do
IntelliJ IDEA -> Preferences... -> Build, Execution, Deployment -> Build Tools -> Gradle -> Gradle JVM
, in case anyone is running into this issue whilst using Gradle. -
chazzlabs over 8 yearsThanks! This resolved my issue after the above answers didn't.
-
Mia over 8 yearsSource: Language Level change to 7 - Diamonds, ARM, multi-catch etc. for IDEA 15
-
iusting over 7 yearsThis should be the accepted answer. As a small heads-up, in IntelliJ IDEA 15, point 4 has moved to
Preferences -> Build, Execution, Deployment -> Compiler -> Java Compiler
. -
jordanpg about 7 yearsThere is also a JRE selection in some run/debug configurations. For example, Tomcat run/debug configs have a "JRE" selector that can cause this error.
-
jordanpg about 7 yearsAlso don't forget the JDK IDEA is running under as well as the JDK used by the underlying OS (for example if you use jenv). See: intellij-support.jetbrains.com/hc/en-us/articles/…
-
AnkitSablok almost 7 yearsI faced the same error and the solution mentioned worked out perfectly fine, the thing is one needs to know what language level was the project compiled in and change the project to use that language level.
-
Amar Gajbhiye over 5 yearsThis really helped. I had changed the version from all the places except Project SDK.
-
Michael Coxon about 5 yearsI tried all of this in 2018.3.6 and nothing worked - I blew away the .idea directory and re-initialised the project - then it worked.
-
Indrajeet Gour about 4 yearsOne more thing i did apart from the mentioned step, edit configuration -> application -> select the your application and check the JRE drop-down and select which you wanted to have in case it was jdk11.
-
Uzair over 3 yearsIf you don't SDK 12. Just add the latest one
-
Admin about 3 yearswhat a legend tysm
-
payne over 2 yearsEnded up having to modify the value of the cloned repo in its root
build.gradle
(thesourceCompatibility
value).