java 不断得到java: invalid source release: 1.9 编译时报错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42650503/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Continuously getting the java: invalid source release: 1.9 error when compiling
提问by Nick Mucci
I have attempted to fix this problem using the various forums on this site, but nothing has helped. I tried similar techniques as used to fix other people's 1.8 errors, but nothing has worked. I have my java class file under my source folder and no imports, I just simply want a basic output message to make sure intelliJ is working as it should. Can anyone offer any advice?
我曾尝试使用本网站上的各种论坛来解决这个问题,但没有任何帮助。我尝试了用于修复其他人 1.8 错误的类似技术,但没有任何效果。我的源文件夹下有我的 java 类文件并且没有导入,我只是想要一个基本的输出消息来确保 intelliJ 正常工作。任何人都可以提供任何建议吗?
回答by Srikanth A
Here change the language level to 1.8 or lesser. This changes the target release version.
此处将语言级别更改为 1.8 或更低。这会更改目标发布版本。
Go to file -> settings -> Build Execution and Deployment -> Java -> Compiler
转到文件 -> 设置 -> 构建执行和部署 -> Java -> 编译器
Here change the language level to 1.8 or lesser. This changes the source release version.
此处将语言级别更改为 1.8 或更低。这会更改源发布版本。
File -> Project Structure -> Module Settings -> Tab: Source: Language Level
文件 -> 项目结构 -> 模块设置 -> 选项卡:来源:语言级别
and also here,
还有这里,
File -> Project Structure -> Project(In left pane) -> Project language level
文件 -> 项目结构 -> 项目(在左窗格中) -> 项目语言级别
回答by D.Nielsen
Just in case anyone stumbles onto the same problem and the above answer doesn't solve it, my issue was resolved doing the following (I was using Gradle):
以防万一有人偶然发现同样的问题并且上面的答案没有解决它,我的问题是通过以下方式解决的(我使用的是 Gradle):
- Open the your-project-name.iprfile.
- Verify the following line:
- 打开your-project-name。.ipr文件。
- 验证以下行:
<bytecodeTargetLevel target="1.xx" />
<bytecodeTargetLevel target="1.xx" />
Mine was set to 1.10
. I changed it to 1.08
(which my project SDK was set to) and the problem was solved.
我的设置为1.10
. 我将其更改为1.08
(我的项目 SDK 设置为)并解决了问题。