Eclipse如何使用JDK8编译项目? [英] How to have Eclipse use JDK8 to compile a project?

查看:125
本文介绍了Eclipse如何使用JDK8编译项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用新的jdk8这里提供的是 http://jdk8.java.net/lambda/



我可以从命令行编译并运行我的项目。



我也可以在Eclipse中将这个新的JDK添加到安装的JREs
但是,我无法使用此JDK编译和运行项目。



我正在尝试更改项目属性/ Java编译器在Java构建路径复选框中使用执行环境中的[JDK]兼容性被禁用,无论我点击这个页面,我都无法使其工作。



我有Eclipse平台版本:3.7.1



任何想法?



thx

解决方案

一个内置的编译器而不是 javac 。内置编译器显然不支持Java 8。



您可以为项目定义一个自定义构建器,它将调用您的 javac 。在项目的首选项中,转到Builders,添加一个新的自定义构建器(可以是Ant脚本或可执行程序),并禁用默认的内置Java构建器。



之后,使用您选择的JDK运行项目不应该是一个问题 - 将其添加到已安装的JRE首选项页面(如您所做)应该是足够的。 p>

I'm experimenting with the new jdk8 what is available here http://jdk8.java.net/lambda/

I'm able to compile and run my project from command line.

I'm also able to add this new JDK to Installed JREs in Eclipse. However, I'm not able to have Eclipse to compile and run the project with this JDK.

I'm trying to change the settings on Project Properties/Java Compiler but the Use [JDK] compliance from execution environment on the 'Java Build Path' checkbox is disabled and no matter whatever I click on this page, I cannot make it work.

I have Eclipse Platform Version: 3.7.1

Any ideas?

thx

解决方案

Eclipse uses a built-in compiler rather than javac. The built-in compiler obviously doesn't support Java 8 yet.

You can define a custom builder for your project which will call your javac. In the project's preferences, go to "Builders", add a new custom builder (which can be either an Ant script or an executable program) and disable the default built-in Java builder.

Afterwards, running the project with the JDK of your choice shouldn't be a problem - adding it to the "Installed JREs" preference page (as you did) should be sufficient.

这篇关于Eclipse如何使用JDK8编译项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆