错误:java :⽆效的源发⾏版:Intellij 中的8。这是什么意思?本⽂翻译⾃:
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: 我正在尝试使⽤Intellij Ultimate 13.1.4编译⼀些代码,但是出现以下错误,我不知道这意味着什么:我正在尝试使⽤Intellij Ultimate 13.1.4编译⼀些代码,但是出现以下错误,我不知道这意味着什么: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: 8java xml是什么
My guess is that its something related to Java 8 vs Java 7, but I have no idea what specifically. 我的猜测是它与Java 8 vs 我的猜测是它与Java 8 vs Java 7有关,但是我不知道具体是什么。Java 7有关,但是我不知道具体是什么。 I've tried to Google around for this message, but they either talk about javac
or target release , so it doesn't exactly seem to apply. 我已尝试在Google周围搜索此消息,但他们要么谈论我已尝试在Google周围搜索此消息,但他们要么谈论javac 要么target release ,所以它似乎并不适⽤。
#1楼
#2楼
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. 将项⽬从Java 8“降级”到Java 6时,我遇到了相同的问题。原因是在IntelliJ中并未在所有地⽅都对其进⾏更将项⽬从Java 8“降级”到Java 6时,我遇到了相同的问题。原因是在IntelliJ中并未在所有地⽅都对其进⾏更改。
In IntelliJ 13.1.4 I had to change Java and SDK version on the following places not to get this error: 在IntelliJ 13.1.4中,我在IntelliJ 13.1.4中,我不得不在以下位置更改Java和SDK版本,以免出现此错误:
File -> Project Structure -> Project Settings ⽂件->项⽬结构->项⽬设置⽂件->项⽬结构->项⽬设置
File -> Project Structure -> Module Settings -> Tab: Sources: Language Level ⽂件->项⽬结构->模块
设置->选项卡:源:语⽂件->项⽬结构->模块设置->选项卡:源:语⾔级别
File -> Project Structure -> Module Settings -> Tab: Dependencies: Module SDK ⽂件->项⽬结构->模块设置->选项卡:依赖⽂件->项⽬结构->模块设置->选项卡:依赖项:模块SDK
File -> Settings -> Compiler -> Java Compiler -> Target bytecode version ⽂件->设置->编译器-> Java编译器->⽬标字节码版⽂件->设置->编译器-> Java编译器->⽬标字节码版本
The last bullet was the one that was not updated in my case. 最后⼀个项⽬符号是我的情况下未更新的项⽬符号。最后⼀个项⽬符号是我的情况下未更新的项⽬符号。 Once I changed this, the error disappeared. 更改此设置后,错误消失了。更改此设置后,错误消失了。
#3楼
Check l first (if you have one) ⾸先检查您的⾸先检查您的l (如果有的话)
(如果有的话) Check your module's JDK dependancy. 检查模块的检查模块的JDK 依赖性。依赖性。 Make sure that it is 1.8 确保它是确保它是1.8
To do this,go to Project Structure -> SDK's 为此,请转到项⽬结构-> SDK 为此,请转到项⽬结构-> SDK
Add the path to where you have stored 1.8 ( jdk1.8.0_45.jdk in my case) 将路径添加到存储1.8的位置 (在我的情况下将路径添加到存储1.8的位置 (在我的情况下为jdk1.8.0_45.jdk )
) Apply the changes 套⽤变更套⽤变更
Now, go to Project Structure ->Modules 现在,转到项⽬结构->模块现在,转到项⽬结构->模块
Change the Module SDK to 1.8 将Module SDK更改为将Module SDK更改为1.8
Apply the changes 套⽤变更套⽤变更
Voila! 瞧!
你完成了
瞧! You're done 你完成了
#4楼
If you are using Gradle as a build tool and you get this error when executing a Gradle task ie TomcatRun take a look to my other answer to the same question 如果您使⽤Gradle作为构建⼯具,
并且在执⾏Gradle任务(例如TomcatRun)时收到此错
如果您使⽤Gradle作为构建⼯具,并且在执⾏Gradle任务(例如TomcatRun)时收到此错误,请查看我对相同问题的其他答案
#5楼
Andreas Lundgren's answer worked and I was able to compile and run my app. Andreas Lundgren的答案奏效了,我得以编
Andreas Lundgren的答案奏效了,我得以编译并运⾏我的应⽤程序。
However, when I tried to run the project's associated JUnit tests I received the same error. 但是,当我尝试运⾏项⽬的关联
但是,当我尝试运⾏项⽬的关联JUnit测试时,我收到了相同的错误。 Running 运⾏
运⾏
JUnit测试时,我收到了相同的错误。
gradle -version
from Windows command prompt showed that gradle was still picking up the incorrect jdk. 从Windows命令提⽰符显⽰
从Windows命令提⽰符显⽰
gradle仍在拾取错误的jdk。
gradle仍在拾取错误的jdk。 To fix it I had to set the JAVA_HOME environment variable to point to the correct jdk and restart IntelliJ. 要修复它,我必须将
要修复它,我必须将JAVA_HOME环境变量设置为指向正确的jdk并重新启动IntelliJ。
#6楼
Change l1.6 to 1.8 将将l1.6更改为1.8
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论