Java 8 is officially available since a couple of days. It was released on March 18th this year. Yeah! But - Eclipse, the biggest and most popular Java IDE is a little bit behind the schedule (at least IMHO). There is no official Eclipse version for Java 8 right now!
But there are two other thing: an up-to-date nightly build of the new Eclipse version Luna which will be released with Java 8 support and a patch for the current Eclipse version Kepler! Since it is sometimes (= always) hard to find the correct Eclipse version on eclipse dot org or anything useful at all, here is how to do it.
Java 8 in Eclipse Juno (4.2)
If you still use Eclipse Juno (4.2), you use an old version of Eclipse without Java 8 support and I strongly recommend to use a new version (as described below). If you cannot do that (or don’t want to do that) here is an old tutorial from me how to setup Java 8 in Eclipse Juno: http://tuhrig.de/java-8-in-eclipse-juno.
Java 8 in Eclipse Kepler (4.3)
Kepler (4.3) is the current version of Eclipse. You can download it from http://www.eclipse.org/downloads. After you downloaded it, it will not have Java 8 support right out of the box! To add it, you have to install a feature patch:
- Download and install Java 8 (e.g. from Oracle JRE/JDK or OpenJDK)
- Add it to Eclipse:
-
Install the feature patch via
Help > Install New Software...
:http://download.eclipse.org/eclipse/updates/4.3-P-builds/
You have to restart Eclipse during the installation and accept a license and click several next-buttons. But after you installed the feature patch, you have Java 8 support in Eclipse Kepler (4.3). If you have problems with the installation process, download a new Eclipse Kepler version.
Java 8 in Eclipse Luna (4.4)
Luna (4.4) is the upcoming version of Eclipse. It will be released this summer and it will contain Java 8 support. But you can already download some nightly builds of it which contains Java 8 support.
You can download Eclipse Luna here. Just make sure you download the correct build version, since not all builds have Java 8 support already! When you download the correct version, you can just run Eclipse and use the new Java 8 features (you also need to install Java 8, e.g. from Oracle JRE/JDK or OpenJDK).
By the way, some nightly builds still contain test errors. This is due to the fact that Eclipse Luna is still in development. But to play around with Java 8 or for a small project it should already be good enough.
A simple Java 8 example
To test your Eclipse IDE, here is a very simple Java 8 example:
public class Test { public static void main(String[] args) { new Thread(() -> System.out.println(“Hello Java 8!”)).start(); } }
Troubleshooting
If you have problems with Java 8 in Eclipse check your project settings. If your compliance level is not set to 1.8
, you cannot use Java 8. And if you don’t even have the compliance level 1.8 then your Eclipse somehow doesn’t support Java 8 and something went wrong. In this case, get yourself a new Kepler version and install the feature patch or download an appropriate Luna build as described above.
Resources
-
For Juno: http://tuhrig.de/java-8-in-eclipse-juno
- For Kepler: https://wiki.eclipse.org/JDT/Eclipse_Java_8_Support_For_Kepler
- For Luna: http://download.eclipse.org/eclipse/downloads
Best regards, Thomas