Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programming Java 8 in Eclipse

Tags:

The development of Eclipse support for Java 8 is ongoing in a branch (http://wiki.eclipse.org/JDT_Core/Java8).

To try out the current Eclipse support for Java 8, I did the following:

  1. I installed a build of JDK 8 (This step is optional).
  2. I checked out branch BETA_JAVA8 of git://git.eclipse.org/gitroot/jdt/eclipse.jdt.core.git.
  3. I imported the checked out projects in an instance of Eclipse Juno SR1 (Build ID: 20120920-0800).
  4. I ran a new instance of Eclipse from my running Eclipse.

To use the new syntax available in Java 8, Eclipse said that I have to set the compliance level of my code to 1.8. To set the compliance level, I have to set the execution environment to JavaSE-1.8. This execution environment was not available at Windows -> Preferences -> Java -> Installed JREs -> Execution Environments.

How can I set the execution environment to JavaSE-1.8?

The following summarizes some of my attempts to install the execution environment:

  1. I followed the wiki instructions looking for a description of JavaSE-1.8 at the update site http://download.eclipse.org/eclipse/updates/4.2. But, the definition of the execution environment wasn't there.
  2. I looked for the JavaSE-1.8 profile in the git repository of rt.equinox.framework, but, it wasn't there.
like image 238
reprogrammer Avatar asked Nov 08 '12 18:11

reprogrammer


People also ask

Does Eclipse work with Java 8?

A Java 8 or newer JRE/JDK is required to run all Eclipse 2019-09 packages based on Eclipse 4.14, as well as the Installer.

How do I change my Java from 11 to 8 in Eclipse?

Click on the Window tab in Eclipse, go to Preferences and when that window comes up, go to Java → Installed JREs → Execution Environment and choose JavaSE-1.5. You then have to go to Compiler and set the Compiler compliance level.

How do I run a Java project in Eclipse 8?

Step 1: Open Eclipse and click File > New > Java Project. Step 2: Provide the Project Name and click on the Finish button. Step 3: In the Package Explorer (left-hand side of the window) select the project which you have created. Step 4: Right-click on the src folder, select New > Class from the submenu.


2 Answers

I just went to the Eclipse Marketplace from inside of Eclipse (Help/Eclipse Marketplace...) and installed the "Java 8 support for Eclipse Kepler SR2", and the new "JavaSE-1.8" execution environment showed up automatically. I had previously installed Java 8 and added it as a 'Installed JREs' entry. No need to mess with property files.

like image 96
Adrian Romanelli Avatar answered Sep 20 '22 01:09

Adrian Romanelli


Think you just have to change the 'settings' directly in the 'preference file' : org.eclipse.jdt.core.prefs .

e.g. org.eclipse.jdt.core.compiler.compliance=1.8

like image 32
Deepak Azad Avatar answered Sep 20 '22 01:09

Deepak Azad