Why won't eclipse switch the compiler to Java 8?

前端 未结 11 1591
无人及你
无人及你 2020-12-09 08:06

I checked out a Java project from SVN in eclipse and realized that it requires Java 8 because it uses lambdas etc. I installed the eclipse addon for Java 8 and restarted ecl

11条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-09 08:41

    Two things:

    First, JRE is not the same as the JDK. If you do have the JDK, you need to configure eclipse to point to that in your settings.

    Second, in your screenshot above, your compiler compliance level is set to 1.7. This will treat all your code as if it's using Java 1.7. Change this to 1.8 to fix your error.

    You will need to have Eclipse Luna in order to get support for Java 8, but you can add it to Kepler SR2 if you want. I'd try with Luna and the above suggestions before you go any further. See this reference.

    Once you get Luna, your JAVA_HOME variable should be enough to get Eclipse to recognize JDK 8. If you want to specify an additional JDK, you can add a new Java System Library by going to:

    Project -> Properties -> Java Build Path -> Libraries -> Add Library -> Java System Library
    

    and navigating to a valid location for the JDK 8.

    You can download your platform's JDK 8 here

提交回复
热议问题