Building and Running Java 8 Support
Building and Running Java 8 Support
Join the DZone community and get the full member experience.Join For Free
The Eclipse support for Java 8 is not yet available for download. If you want to play with it, you’ve got to build it. Eclipsepedia’s JDT Core/Java8 page includes instructions for setting up your development environment with the source for the evolving Java 8 support in the Eclipse Java development tools (JDT). There’s a few pieces missing from the instructions; I’ll circle back later and add them in.
I started by installing Java Development Kit (JDK) 8. I didn’t look very hard for an RPM; instead, I just went straight to the source. For Linux, it comes as a tar.gz file that I just decompressed into a working directory.
Next, I downloaded the latest milestone build of the Eclipse SDK (4.4M5 at the the time of writing). This isn’t a stated requirement, but I decided that it would be a good starting point. I configured the “vm” option in the eclipse.ini file to use the Java 8 JRE included with the downloaded JDK. I added “Git Team Provider” to the SDK from the Luna software repository.
The JDT is spread across a small number of Git repositories:
- JDT Core git://git.eclipse.org/gitroot/jdt/eclipse.jdt.core.git
- JDT UI git://git.eclipse.org/gitroot/jdt/eclipse.jdt.ui.git
- JDT Debug git://git.eclipse.org/gitroot/jdt/eclipse.jdt.debug.git
Some Equinox updates are also required (I believe that this primarily to provide the required Java 8 Execution Environment).
In all repositories, the code is contained in the BETA_JAVA8 branch. I cloned all of these repositories and used the handy “Import all projects” feature to automatically pull all the code into my workspace.
At this point, my Package Explorer contained a lot of red marks. Many of the plug-ins are configured to be compiled by very specific Java versions that I did not already have installed. So, I hunted down JDKs for Java 1.4, 5, and 6 (I already had Java 7 installed). I opted to download the self-extracting archives.
I added each of these to the “Installed JREs” page in the preferences.
Then I configured execution environment mappings for each JRE.
This made most, but not all, of the red marks disappear.
Per the instructions, I downloaded Eclipse SDK 4.3.1 for use as a clean target platformand API baseline (though I suspect that it’d be just fine to use the 4.4M5 for both). Frankly, I don’t recall if any more of the red marks disappeared with this step.
I decided to go for it in spite of the remaining red marks (which appear to be tests that I haven’t properly configured), and set up a launch configuration. It’s alive.
I started by tinkering a bit with lambda expressions.
The short version is that the Eclipse compiler for java (ECJ) handles them well. Content assist isn’t quite baked yet, but syntactically-correct lambda expressions compile and run as expected. It’s clear from the activity in Bugzilla, that this is moving along quickly.
As an Old Guy who Knows Smalltalk, my first instinct is to create Smalltalk-like collections in Java.
| employees names | employees := OrderedCollection new add: (Employee named: 'Wayne'); add: (Employee named: 'Joel'); add: (Employee named: 'Jon'); add: (Employee named: 'Anthony'); yourself. names :=employees collect: [:employee | employee name]. output >> an OrderedCollection('Wayne' 'Joel' 'Jon' 'Anthony')
OrderedCollection employees = new OrderedCollection(); employees.add(new Employee("Wayne")); employees.add(new Employee("Joel")); employees.add(new Employee("Jon")); employees.add(new Employee("Anthony")); OrderedCollection names = employees.collect(employee -> employee.name); output >> [Wayne, Joel, Jon, Anthony]
Please note the disclaimer on the bottom of the JDT Core/Java8 page:
This is a work in progress. The contents of the BETA_JAVA8 branch will be updated as the changes are made to the JSR Specification. Please use the early access builds only in a test/evaluation mode and not in the real development environment. If you need any help with this, please contact the JDT/Core team through either the forum or Bugzilla.
Published at DZone with permission of Wayne Beaton , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.