IntelliJ 使用 Java 8 SDK 为 Java 7 JRE 编译
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25115059/
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
IntelliJ compile for Java 7 JRE using Java 8 SDK
提问by arik
I have the Java 8 SDK and runtime, and a project that is only using Java 7 features. I was wondering whether I could set up intellij to build a Java-7-level jar, something that is definitely possible from command line?
我有 Java 8 SDK 和运行时,以及一个仅使用 Java 7 功能的项目。我想知道我是否可以设置 intellij 来构建 Java-7 级别的 jar,这绝对可以从命令行实现?
So far, I have tried simply setting the project language level to 7 as an experiment, but that is obviously insufficient and not really what I need.
到目前为止,我已经尝试简单地将项目语言级别设置为 7 作为实验,但这显然是不够的,也不是我真正需要的。
I have also seen this question on SO: "Intellij IDEA using java7 compiler to compile when I have configured it to use Java6", but my project SDK is already set up to the newest Java version, and I merely need a Java-7-compatible artifact/jar compilation.
我也在 SO 上看到过这个问题:“ Intellij IDEA using java7 compiler to compile when I have configure it to use Java6”,但我的项目 SDK 已经设置为最新的 Java 版本,我只需要一个 Java-7-兼容的工件/jar 编译。
EDIT: I only have Java 6 and Java 8 JREs/SDKs on my local system because unfortunately Java 7 has issues on my system and is not compatible.
编辑:我的本地系统上只有 Java 6 和 Java 8 JRE/SDK,因为不幸的是 Java 7 在我的系统上有问题并且不兼容。
回答by EpicPandaForce
File -> Settings -> Compiler -> Java Compiler -> Project bytecode version -> 1.7
文件 -> 设置 -> 编译器 -> Java 编译器 -> 项目字节码版本 -> 1.7
回答by Yurii Bondarenko
- Select root of your project.
- Press F4
- Select language level.
- 选择项目的根目录。
- 按F4
- 选择语言级别。