简体   繁体   English

IntelliJ IDEA中的项目语言级别是什么?

[英]What is Project Language level in IntelliJ IDEA?

I am using Java 7 SDK and IntelliJ IDEA IDE. 我正在使用Java 7 SDK和IntelliJ IDEA IDE。

java version "1.7.0_11"
Java(TM) SE Runtime Environment (build 1.7.0_11-b21)
Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)

I am still not able to use Java 7 features. 我仍然无法使用Java 7功能。 After a bit of googling I could use all the features after setting project language level to 7(Diamond, ARM, multicatch etc) . 经过一些谷歌搜索后,我可以在将项目语言级别设置为7(Diamond, ARM, multicatch etc)后使用所有功能。 What exactly is this? 究竟是什么? If this has some relationship to syntax based on JDK in use what is level 8(Lambda, annotations etc) ? 如果这与基于JDK的语法有某种关系,那么level 8(Lambda, annotations etc)什么? Java 8 isn't released yet. Java 8尚未发布。 Java 8 is expected in March 2014 according to Wiki. 根据Wiki,预计Java 8将于2014年3月发布。 Someone please explain this language level concept. 有人请解释这个语言水平的概念。

The Language level setting sets which features the code assistance in the editor should support. Language level设置设置编辑器中应支持的代码帮助功能。 For example, if you're using JDK 1.7 but want your code to be compatible with JDK 1.6, you can set the language level lower than your actual JDK supports (6.0 in the case of JDK 1.6) and only get refactorings/syntax suggested that are supported on 1.6 and lower. 例如,如果您正在使用JDK 1.7但希望您的代码与JDK 1.6兼容,则可以将语言级别设置为低于实际JDK支持(在JDK 1.6的情况下为6.0),并且仅获得重构/语法建议支持1.6及更低版本。 Depending on your compiler, it may also give the compiler options to remove support for newer syntax elements. 根据您的编译器,它还可以为编译器选项提供删除对较新语法元素的支持。

The 8.0 (which, as you're guessing corresponds to Java 8) is available for people that want to experiment with one of the Java 8 snapshots that are available. 8.0(正如您猜测的那样对应于Java 8)可供希望尝试使用其中一个Java 8快照的人使用。 Since Java 8 isn't released, language level 8.0 may very well change before release. 由于Java 8未发布,语言级别8.0可能会在发布之前发生很大变化。

As per the documentation within section Exploring the General Project Settings at the IntelliJ Wiki , the project language level impacts the intellisense provided by the IDE. 根据IntelliJ Wiki中 探索常规项目设置部分中的文档,项目语言级别会影响IDE提供的智能感知。

It also dictates the behavior of the compiler being used by IntelliJ when it compiles your Java code as you develop. 它还规定了IntelliJ在开发时编译Java代码时使用的编译器的行为。

This setting tells all the facilities of the compiler that would be available for the project. 此设置告诉编译器可用于项目的所有工具。 For eg setting the language level to JDK 5 will allow the IntelliJ to recognize keywords such as enum that are present within the source code. 例如,将语言级别设置为JDK 5将允许IntelliJ识别源代码中存在的关键字,例如枚举

If you look at the options for the javac Java compiler command , you'll see that the -source and -target options allow you to compile against alternate versions of Java. 如果查看javac Java编译器命令选项 ,您将看到-source-target选项允许您针对Java的备用版本进行编译。 I'm not sure to which option IntelliJ's language level setting corresponds (it is likely -source ), but it essentially tells IntelliJ to use the provided Java SDK (in the Project SDK field) in the specified Java language version instead of the latest provided by said SDK. 我不确定IntelliJ的语言级别设置对应哪个选项(很可能是-source ),但它实质上告诉IntelliJ使用指定Java语言版本中提供的Java SDK(在Project SDK字段中)而不是最新提供的通过说SDK。

So while you have Java 7 installed, you could set the language level to 6.0 , and IntelliJ will compile your code against the Java 6 specification instead of the Java 7 spec. 因此,在安装Java 7时,可以将语言级别设置为6.0 ,IntelliJ将根据Java 6规范而不是Java 7规范编译代码。 This includes all of the real-time suggestions and code checking done as you type. 这包括您键入时所做的所有实时建议和代码检查。

The Java 8 option is there likely due to the fact that beta builds of Java 8 are available for testing. Java 8选项可能是因为Java 8的beta版本可用于测试。

I've never experimented with what would happen if you set a language level to something higher than the JDK version. 如果你将语言级别设置为高于JDK版本的东西,我从未尝试过会发生什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 每次重新加载 pom 时停止 IntelliJ IDEA 切换 java 语言级别(或更改默认项目语言级别) - stop IntelliJ IDEA to switch java language level every time the pom is reloaded (or change the default project language level) 将Intellij Idea编译器语言级别设置为1.3 - Set Intellij Idea Compiler Language Level to 1.3 使用IDE支持,使Intellij IDEA允许在Java 5 6 7语言级别使用lambda - Make Intellij IDEA allow lambda in java 5 6 7 language level with IDE support 在IntelliJ IDEA插件中获取项目级别服务的项目 - Get the project of a project level service in IntelliJ IDEA plugin 如何在IntelliJ IDEA中设置多语言项目 - How to set up a multi-language project in IntelliJ IDEA 无法解决IntelliJ上与项目语言级别有关的源错误 - Can't resolve -source errors on IntelliJ with regards to Project Language Level 为什么我无法在IntelliJ IDEA中选择某个语言级别以上? - Why am I not able to select above a certain language level in IntelliJ IDEA? 在 Gradle 和 IntelliJ 中设置语言级别 - Set language level in Gradle and IntelliJ 在IntelliJ上配置默认语言级别 - Configure default Language Level on IntelliJ 如何在IntelliJ IDEA中将Maven多模块项目的嵌套模块显示为顶级模块? - How to show Maven multi-module project's nested-modules as top level modules in IntelliJ IDEA?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM