There are still about five and a half months to wait for the General Availability (GA) of Java 8. It is announced for 18th March of 2014. For all that cannot wait until to test the new features with an IDE: this post describes how you can do it with the most recent version of Eclipse Luna.
In order to try out Eclipse with Java 8 you will have to
- download and install JDK 8
- clone Eclipse repository
- build Eclipse
- configure Eclipse
The Steps
Before you start please check if your system fulfills all necessary prerequisites. Depending on your system hardware and internet bandwidth the execution of the build script can take quite a long time (~8 hours in the author’s case).
- Download the Early Access (EA) distribution of JDK 8.
- Unpack the JDK archive file to an arbitrary directory.
- Create a directory for the build and export its file system path to a system variable named ECLIPSE_BUILD_HOME.
- Create an executable build script file with the following content:
1234567#!/bin/shexport MAVEN_OPTS="-Xmx2048m -XX:PermSize=2048m"cd $ECLIPSE_BUILD_HOMEgit clone -b BETA_JAVA8 --recurse-submodules \git://git.eclipse.org/gitroot/platform/eclipse.platform.releng.aggregator.gitcd $ECLIPSE_BUILD_HOME/eclipse.platform.releng.aggregatormvn clean verify
- Execute the build script. Wait and be patient…
- Unless the build script execution failed the Eclipse distribution should be available at
$ECLIPSE_BUILD_HOME/eclipse.platform.releng.aggregator/eclipse.platform.releng.tychoeclipsebuilder/sdk/target/products/org.eclipse.sdk.ide/linux/gtk
. Choose the distribution appropriate to your OS’ architecture and copy it to a directory of your choice. - Start Eclipse and specify a workspace directory.
- Add JDK 8 to the Installed JREs (
Window - Preferences - Java - Installed JREs - Add...
) and set it as default JRE. - Create a Java project and add the following class to the default package:
1234567public class HelloJava8 {public static void main(String[] args) {Runnable func = () -> { System.out.println("Hello Java 8!"); };func.run();}}
- Outside Eclipse, open the file
org.eclipse.jdt.core.prefs
contained in the Java project’s.settings
directory. Change the values of theorg.eclipse.jdt.core.compiler.compliance
andorg.eclipse.jdt.core.compiler.source
settings to ‘1.8’. - Within Eclipse, refresh and recompile the Java project. Now the compile error should have disappeared.
- Run the Java project and verify the console output. It should print out ‘Hello Java 8!’.
- Enjoy 🙂
Author’s System Environment
Please regard that this is just a listing of the author’s system environment under which the build succeeded. However, the Eclipse Wiki manages build instructions for other system environments, too.
- Linux Mint Lisa KDE
- Git 1.7.5.4
- Java JDK 1.7.0_40 64-Bit
- Java running in ‘Server’ mode (see http://wiki.eclipse.org/Platform-releng/Platform_Build#Java_Server_Mode)
- JAVA_HOME variable set to home directory of Java
- Apache Maven 3.0.5
- MAVEN_HOME variable set to home directory of Maven
- Default Maven settings (i.e. untouched
~/.m2/settings.xml
) - ~22 GB of free HDD space