eclipse java不能编译器,为什么eclipse不会将编译器切换到Java 8?

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 eclipse and and have the project set up like so:

wt552.png

I noticed that near the bottom, it says that the default compiler compliance is 1.7, so I went into org.eclipse.jdt.core.prefs and set the compiler compliance variable to 1.8, as per

this answer. However, in Project -> Preferences -> Java Compiler, it still shows up as:

KCaiL.png

I have set the JRE in Project -> Java Build Path:

IEeZY.png

Yet the compiler refuses to compile lambda expressions - I get an error that looks like what I would get if I went ahead and typed it into Java 7.

This is the version of eclipse I'm using

Version: Kepler Service Release 1

Build id: 20130919-0819

Is the only way to solve this to install a fresh version of Eclipse or am I missing something in the configuration?

解决方案

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值