Intellij - 错误:java:无效的源版本:1.8 [英] Intellij - Error:java: invalid source release: 1.8
问题描述
在尝试运行测试时,我遇到了这个编译错误:
While trying to run tests, I ran into this compilation error:
我尝试在谷歌和此处进行研究,在应用了所有适用于其他人的解决方案后,这个问题仍然存在仍然存在。
这是我到目前为止所做的:
I tried researching this on Google and here, and after applying all of the solutions that worked for others this issue still persists. Here is what I have done so far:
- 首选项 - > Java编译器:将'project bytecode version'设置为1.8
- 我还为每个单独的模块设置目标字节码版本为1.8
我认为此问题可能与JDK和编译器之间的差异。
当我从终端运行java -version
时,它返回1.8.0_111。但是,当我运行javac -version
时,它返回1.7.0_79。我想方法强制更改javac版本以匹配java版本,但几乎所有版本都引用update-alternatives
,这些不适用于Mac OS或删除/ usr / bin在El Capitan上不允许(甚至使用sudo)。I think this issue may have something to do with a discrepancy between the JDK and the compiler. When I run
java -version
from the terminal it returns 1.8.0_111. However when I runjavac -version
it returns 1.7.0_79. I looked for ways to force change the javac version to match the java version but nearly all of them referenceupdate-alternatives
which is not available for Mac OS or removing /usr/bin which is not allowed (even with sudo) on El Capitan.解决方法编辑:
我可以通过转到首选项 - >构建,执行,部署来绕过此问题 - >编译器 - > Java编译器,将编译器从javac更改为Eclipse,我可以编译我的项目。Workaround
I was able to bypass the issue by going to Preferences -> Build, Execution, Deployment -> Compiler -> Java Compiler and changing the compiler from "javac" to "Eclipse" and I am able to compile my project.推荐答案
- 安装jdk1.8。*
- 更改SDK到jdk1.8。*
- 完成
这篇关于Intellij - 错误:java:无效的源版本:1.8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!