What is the Project Language level in IntelliJ IDEA?

I am using the Java 7 SDK and 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 still can’t use the functions of Java 7. After several searches, I was able to use all the functions after setting the project language level to 7(Diamond, ARM, multicatch etc) . What exactly is this? If this is due to JDK-based syntax, is level 8(Lambda, annotations etc) ? Java 8 has not yet been released. Java 8 is expected in March 2014 according to the Wiki. Someone please explain this concept of language level.

+45
java intellij-idea
Jul 18 '13 at 4:31 on
source share
3 answers

Language level parameter sets that support code support in the editor must support. For example, if you use 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-supporting (6.0 in the case of JDK 1.6), and only get refactoring / syntax to support 1.6 and below. Depending on your compiler, it may also enable compilers to remove support for new syntax elements.

8.0 (which, you guessed it, corresponds to Java 8) is available for people who want to experiment with one of the Java 8 snapshots that are available, since Java 8 is not released, the language level 8.0 can very well change before release.

+68
Jul 18 '13 at 4:53 on
source share

According to the documentation in the Exploring General Project Settings section of the IntelliJ Wiki, the effect of the intellisense project language level provided by the IDE.

It also dictates the behavior of the compiler used by IntelliJ when it compiles your Java code during development.

This parameter tells all the compiler tools that will be available for the project. E.g. setting the language level in JDK 5 will allow IntelliJ to recognize keywords, such as enumerations , that are present in the source code.

+3
Jul 18 '13 at 4:50
source share

If you look at the javac Java compiler command options, you will see that -source and -source options allow you to compile alternative versions of Java. I'm not sure which parameter matches the IntelliJ language level (this is most likely -source ), but essentially tells IntelliJ to use the provided Java SDK (in the Project SDK field) in the specified version of the Java language instead of the last provided by the mentioned SDK.

So, if you have Java 7 installed, you can set the language level to 6.0 , and IntelliJ will compile your code according to the Java 6 specification instead of the Java 7 specification. This includes all the real-time suggestions and code verification performed as you type.

The Java 8 option is probably related to the fact that beta versions of Java 8 are available for testing.

I have never experimented with what will happen if you set the language level to something more than the JDK version.

+3
Jul 18 '13 at 4:55
source share



All Articles