in Coding, Java

Java 8 in Eclipse (Juno)

Note: Here is an up-to-date tutorial for the new Eclipse versions Kepler and Luna:

Since last July the new Java 7 is generally available. However, even the newer Java 8 is already available as an Early Access Preview. It can be download as part of the OpenJDK including lambda-support. To use it with Eclipse, some additional steps are required. Here’s how it goes:

  1. Download the JDK from and install it.
  2. Create a new Java project in Eclipse.
  3. Change some project settings in Eclipse in order to use the new javac compiler of Java 8:
    1. Click right on your project and select Properties.
    2. Select Builders on the left side and uncheck the default Java Builder.
    3. Click on New and select Program as the type of the new builder.
    4. Open javac from the JDK 8 on your disk (it’s in the folder bin).
    5. Configure the new builder by providing some arguments:
    6. Select the tab Build Options and check the During auto builds box, to let the builder run automatically.
  4. Done! Now you can write and execute Java 8 code!

The main feature of Java 8 is the ability to write lambdas and use a functional-like programming style. This can be very useful, especially in GUI-programming. It can reduce the amount of code, because anonymous classes that only implements a listener-interface are avoided. Here’s a very simple example:

The code creates a common JFrame with two buttons. To each button an action-listener is added. But instead of implementing an anonymous class, a method reference is passed in the first case and a lambda in the second case. This reduces the amount of code compared with the old solution that looked like this:

However, the Java compiler will create exactly such a thing of the lambda expression or function reference. Therefore, the passed method must fulfill the interface described by ActionListener. Also, we can only use lambdas instead of interfaces that only describe one single method. Such interfaces are called functional interfaces.

Since Eclipse Juno is made for Java 7 it will not recognize the new lambda syntax. Hence, the editor will mark parts of the code as red errors. But it’s still possible to compile and to execute the code using the new javac compiler form Java 8.

Best regards,
Thomas Uhrig

Write a Comment



  1. Hey guys,

    I’m having a small problem with step 5. Could someone please break down for me what
    -d ${workspace_loc:/Java8}/bin ${workspace_loc:/Java8}/src/de/tuhrig/java8/*.java means?
    I’m assuming it’s the path of the workspace and the path of the java 8 download but I’m not sure because when I change it to suit my locations on my computer I’m getting errors saying Javac: file not found.

    Thanks. Leornard.

    • Hi Leonard!

      The argument -d ${workspace_loc:/Java8}/bin ${workspace_loc:/Java8}/src/de/tuhrig/java8/ is not the location of your JDK. It is your Eclipse project. You got a workspace (${workspace_loc:/Java8}) which contains a project called Java8. Inside this project you have a bin folder which contains the compiled results of your Java source file (which are located in /src/de/tuhrig/java8).

      By the way: This article is very old. If you use the latest version oft Eclipse, you don’t need to do this stuff anymore.

      Best regards, Thomas.

      • I am using Juno 4.2 ,did above steps, getting error :

        Errors occurred during the build.

        Errors running builder ‘Integrated External Tool Builder’ on project ‘VehicleMaintenance’.

        The builder launch configuration could not be found.

        The builder launch configuration could not be found.

  2. Hi currently i am working with ecipse juno under cloudsim. After updating the java to version 8, when i try to run the eclipse from my dekstop, it is not running. whats the problem? could you please rectify it.


  • Java 8 in Eclipse (Kepler and Luna) | Thomas Uhrig August 22, 2017

    You don’t actually “run” step 5. It’s a configuration which you enter in your builder settings in Eclipse. Look for some input field called “arguments”.

  • Using Apache Commons Functor functional interfaces with Java 8 lambdas « Bruno P. Kinoshita August 22, 2017

    You don’t actually “run” step 5. It’s a configuration which you enter in your builder settings in Eclipse. Look for some input field called “arguments”.