错误:java:无效标志:-release
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40448344/
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
Error:java: invalid flag: -release
提问by Sergii Getman
I use Java:
我使用Java:
Java(TM) SE Runtime Environment (build 9-ea+143) Java HotSpot(TM) 64-
Bit Server VM (build 9-ea+143, mixed mode)
and IntelliJ IDEA:
和IntelliJ IDEA:
IntelliJ IDEA 2016.2.5 Build #IU-162.2228.15, built on October 14,
2016
Get error when compiling:
编译时报错:
Error:java: invalid flag: -release
Executing javac -help
:
执行javac -help
:
--release <release>
Compile for a specific VM version. Supported targets: 6, 7, 8, 9
So javac
should use two hyphens with release, but Intellij Idea use with one.
所以javac
应该在release 中使用两个连字符,但 Intellij Idea 使用一个。
Can I override javac
options that IDEA use or fix it in some way?
我可以覆盖javac
IDEA 使用的选项或以某种方式修复它吗?
UPD: Even Build, Execution, Deployment > Compiler > Java CompilerAdditional Command Line Parameter doesn't help in this case
UPD:即使构建、执行、部署 > 编译器 > Java 编译器附加命令行参数在这种情况下也无济于事
采纳答案by Nicolai
Java 9 support is cutting edge and should be tried with the most current version. At the moment, this is the public preview of 2016.3, available here.
Java 9 支持是最前沿的,应该尝试使用最新版本。目前,这是 2016.3 的公开预览版,可在此处获得。
回答by Dunx
Had exactly the same Error:java: invalid flag: -release
in Intellij 2017.1. Updating to 2017.2.5 resolves the issue.
究竟有同样Error:java: invalid flag: -release
的的IntelliJ 2017.1。更新到 2017.2.5 解决了这个问题。
回答by Adelin
As specified in this intellij threadyou can workaround it by setting the project SDK language level to x - Experimental Features
正如在这个 Intellij 线程中指定的,您可以通过将项目 SDK 语言级别设置为 x 来解决它 - 实验性功能
回答by Etibar Hasanov
I had the same problem with IntelliJ IDEA Version 2017.1.3
我在 IntelliJ IDEA 版本 2017.1.3 上遇到了同样的问题
Updated IntelliJ to Version: 2017.3.4and with the latest version it works fine.
将 IntelliJ 更新到版本:2017.3.4并且使用最新版本可以正常工作。
回答by Bohdan
Can be caused by mismatch of java version on build configuration and module settings.
可能是由于构建配置和模块设置上的 java 版本不匹配造成的。
回答by Roberto
I was using Java 8 and Intellij 2018.1.1
我使用的是 Java 8 和 Intellij 2018.1.1
I solved the issue in this way:
我以这种方式解决了这个问题:
- open IntelliJ Idea settings
- navigate to Build, Execution, Deployment> Compiler> Java Compiler
- Uncheck the option:
Use '--release' option for cross-compilation (Java 9 and later)
- 打开 IntelliJ Idea 设置
- 导航到构建、执行、部署>编译器> Java 编译器
- 取消选中该选项:
Use '--release' option for cross-compilation (Java 9 and later)
回答by Kumar Vaduganathan
回答by Narendra
You can check the JDK version, if its less than JDK8, upgrade and try again. It solved my issue.
您可以检查JDK版本,如果低于JDK8,请升级并重试。它解决了我的问题。