What is "compiler compliance level" in Eclipse?

The compiler compliance setting tells the compiler to pretend it's a different version of Java.

The Java 8 compiler will produce class files in the Java 8 version of the class file format, and accept Java 8 source files. JRE 6 can't load this version, because it was created after JRE 6 was.

If you set the compliance level to "JRE 6", it will instead compile Java 6 source files into Java 6 class files.

It's like saving a Word document as "Word 97-2003 format" - so that Word 97-2003 can read your document. You're saving the class files in Java 6 format so that Java 6 can read them.


It tells you what version of the JDK you are adhering to; specifically, which JRE are you targeting with your build.

It is the MINIMUM JRE needed to run your code


The Java compiler can compile code that will run on prior versions of the JVM. Even if you have JDK 6 installed, you could be writing code targeted for people that use JDK 5. The Compiler Compliance level tells Eclipse to use appropriate settings when compiling your project to ensure you code will work on the target JVM you specify. By default, if I recall, Eclipse picks Java 5 Compliance. If you want to use code features specific to Java 6 or Java 7, you will have to change the compliance level.


The simplest way to describe the "Java compiler compliance" setting is that it determines which Java Virtual Machine instructions may be used in the "compiled" Java code ... and which library class versions are to be used. Each release of the JVM (and its libraries) may introduce new instructions (the VM) or adjust the class libraries that are delivered along with the JVM.

You should set the setting to the lowest level of JVM that you expect your product to be run on.