37

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

Eng.Fouad
  • 115,165
  • 71
  • 313
  • 417
bpgergo
  • 15,669
  • 5
  • 44
  • 68

5 Answers5

21

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.

Deepak Azad
  • 7,903
  • 2
  • 34
  • 49
Eli Acherkan
  • 6,401
  • 2
  • 27
  • 34
11

Eclipse now supports JDK 8 EA:

The Eclipse JDT/Core team is pleased to announce the availability of early access builds with support enabled for the following Java 8 features.

We recommend that you start with a clean install of

This update site is set up to periodically rebuild and package the relevant projects from the top of the BETA_JAVA8 development branch.

Source: http://dev.eclipse.org/mhonarc/lists/eclipse-dev/msg09679.html


EDIT:

After upgrading eclipse, you need to change the JDK and the compiler level. Here is a screenshot of using lambda within Eclipse:

enter image description here

Eng.Fouad
  • 115,165
  • 71
  • 313
  • 417
  • Oops, it seems that `sorted()` doesn't work well with `parallelStream()`. – Eng.Fouad Oct 22 '13 at 23:02
  • Well, it turns out that I need to use `forEachOrdered()` instead of `forEach()`: http://stackoverflow.com/questions/19529982/java-8-parallelstream-with-sorted – Eng.Fouad Oct 22 '13 at 23:33
5

go window->preferences->Java->Installed JREs->execution environment->Java SE-1.8

3

I did it this way:

1.Right click on JRE System Library on Package Explorer and select Properties (On your right side)

Right click on JRE System Library on Package Explorer and select Properties (On your right side)

  1. Change your execution environment.

Change your execution environment

Hunter
  • 3,080
  • 20
  • 23
2

You can pretty much forget about that, as even the plan for eclipse 3.8 only says "Start to work on Java 8 support."

Working with the bleeding edge has its drawbacks...

Michael Borgwardt
  • 342,105
  • 78
  • 482
  • 720
  • Thanks! I don't accept it right now, I'm waiting if somebody could come up with a suggestion/workaround. – bpgergo Nov 14 '11 at 14:43