javaeclipsecompiler-version

Why does Eclipse complain that the project specifies compiler compliance 1.8 but a JRE 11 is used?


I set an Eclipse project compiler compliance to 1.8 because I want to generate jar files that can be executed in computers with JRE 8 installs.

However, in my development computer I only have JRE 11 installed. I assumed this to be ok because I expected a JRE 11 to be able to execute 1.8 files and above.

However, Eclipse produces a warning about this (which I cannot find a way to disable), and the compiler preferences dialog says "When selecting 1.8 compliance, make sure to have a compatible JRE installed and activated (currently 11)", which makes is sound like a JRE 11 is not compatible with 1.8. Is that really the case?

What wrong assumptions I am making here, exactly?

Also, do I really need to have a JRE 8 installed in order to produce JRE 8-compatible code?


Solution

  • In Project > Properties: Java Compiler check the Use '--release' option checkbox to avoid the warning.

    With Use '--release' option and the compiler compliance level set to 1.8, for example " foo ".strip() is shown as an error even with a Java 11 JDK because String#strip() which was introduced in Java 11 is missing in Java 8.

    enter image description here

    See also: