Programming Java 8 in Eclipse - java

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:
I installed a build of JDK 8 (This step is optional).
I checked out branch BETA_JAVA8 of git://git.eclipse.org/gitroot/jdt/eclipse.jdt.core.git.
I imported the checked out projects in an instance of Eclipse Juno SR1 (Build ID: 20120920-0800).
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:
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.
I looked for the JavaSE-1.8 profile in the git repository of rt.equinox.framework, but, it wasn't there.

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.

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

If you have Kepler you can get it using a patch that has installation instructions on this page:
https://wiki.eclipse.org/JDT/Eclipse_Java_8_Support_For_Kepler
Starting with I20140318-0830 all Luna (4.4) builds on our downloads
page contain the Eclipse support for Java™ 8. For Kepler SR2 (4.3.2) a
feature patch needs to be installed. This page describes how to do
this.

Eclipse version >=Luna (that's one after Kepler) runs smoothly with java 8.

Related

How to Use Java 8 settings to build project in eclipse 4.18(2020-12)

*Due to some project requirements I "have" to use eclipse 4.18 (2020-12) which uses Java 11 by default and is mandatory to start.
But my entire project is/was written in Java 1.7 earlier. Now , in my mac i have both java 1.8 and 11 installed also my eclipse settings are such shown below.
I have made sure removed all java 11 references in my eclipse and made the project and workspace configure to take the 1.8 jdk and run at 1.7 compiler level.*
but when i run ,project -->clean-->build, i run into the JaxB missing in java 11 ( in java 11 JAXB was removed and my project uses jaxB extensively) This is known.
So i am wondering what am i missing that my projects are still building my project with java 11 and not java 1.7 (using jdk 1.8 configured).
Please help.. stuck on this since some days.
machome
Eclipse Compiler setting-1
Eclipse Setting Execution Envs
Eclipse installed JRE's
Eclipse Project specific setting
Java 11 JaxB error
If Eclipse itself is being run with Java 11, and you have a plug-in installed that has not been properly update to work under Java 11, as it appears, you will need an updated version of that plug-in. Update to the latest "oracle design studio", and if you still see this problem, contact Oracle support.
The latest Eclipse may require Java 11 to run, but it's simple to set up Eclipse projects that use older Java versions. Don't mess with the Java version it uses to start up, as long as that is a proper Java 11 version.
As one commenter mentions, you'll have to have a particular Java distribution configured in "Installed JREs->Execution Environments", and then you'll have to have the project configured to use that Java version symbol, like "JavaSE-1.7".

How can i use eclipse 2020-09 to develop java 8 projects?

I am a regular IntelliJ user, but most of my co-workers use Eclipse. A lot of them say the latest version of Eclipse "2020-09", which requires a JRE "higher than Java 8" in order to run, cannot be used to develop projects requiring JRE8.
This is pretty surprising to me, since I know it is possible to install multiple JDKs and JREs on one machine, I've done it plenty of times.
What is the typical way a person would configure Eclipse 2020-09 (already installed) to work on a project that requires a Java 8 JRE?
JRE 8 apps in eclipse workspace is possible by having the jre 8 jdk. It is true that in order to use eclipse 2020-09 you need java 11+ jdk/jre, but making projects that support jre 8 is still possible.Even I still use 2020-06 and before. Here is a method you could use to get JRE 8 implemented back in your project. Although you can change the defaults, this one will help you change the environment back to java 8 for 1 project.
Right click the library named somthing like "JRE system library[JavaSE-11]". Press properties. This is what you will see JRE System Library chooser image
Choose "Alternate JRE" then click "Installed JREs"Step Image
Press "Add" then you will see 3 options. Choose standard VM. Find your java 8 jdk directory. Usually it is something like C:\Program Files\Java\jdk1.8.0_251.
You can configure the default arguments for your jvm runtime. Then simply hit ok,select the jdk-8 library and close it. Then choose alternate jre again and in the drop-down choose jdk-1.8.0 or some name like that. This will only work if you also have java 8 installed alongside java 11 that is configured properly JDK
You can use Java 11 to start the Eclipse 2020-09 and configure a project to compile with Java 8. The problem is if you want a Eclipse plugin that uses CORBA for example. This module was removed from Java 11 earlier. In this case, I recommend to use Eclipse 2020-06.
Earlier versions of 2020-09 was working with Java 8. I had it, too. Then I updated and I got the same error message like you.
I propose to use an older one or to install JRE 11 and set the JAVA_HOME env variable to it.
The inside the IDE you can set java 8 like an JDK and develope your project with Java 8 while eclipse is running with 11.

JRE version is 1.6.0; version 1.7.0 or later is needed to run Google Plugin for Eclipse

I have 3 versions of Java installed on my system: 6, 7, and 8... I am required to have JRE6 available for a product my company develops, so I cannot get rid of it... But despite copying my Eclipse install to a new folder for another project I need to work on and removing JRE6 from this version alltogether, I still cannot get it to work.
How can I get the google plugin for Eclipse to work in my scenario?
If you have created a shortcut to start eclipse, you can add a parameter to tell it to use the jre of your choice like this -
C:\eclipse\eclipse.exe -vm "C:\Programs\jdk\jdk1.7.0_55\bin\javaw.exe"
I have used "javaw" executable from a jdk installation, but you may point to the same executable within a JRE installation as well.
This will resolve the error.
Keep in mind that there is a separation between the JVM that Eclipse itself is running in and the various JREs that you can configure in Eclipse to run your programs/applications. You need to specify to Eclipse what JVM you want it to run under, using eclipse.ini.
That's separate from the Installed JREs configuration you show in your screen shot above.
Add Java 7.0 to Eclipse if you haven't: Window -> Preferences -> Java -> Installed JREs.
Next add Java 7.0 library to your project: Right click on project -> Properties -> Java Build Path -> Libraries tab -> Remove JRE 1.6 and add New Library (JRE System Library, 1.7.0).
Last set Java 7.0 compliance level: Right click on project -> Preferences -> Java Compiler -> Compiler compliance level: 1.7
Also since you can use different Java to run applications, you also have to change this in the Run configuration which you use to start AppEngine related tasks.

How to set eclipse with JRE 8?

I tried to update my jre version in eclipse,
I added the jre 8 to my installed JRE's an checked him.
When I click OK it gives me an ERROR:
The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from
required .class files
It happens only when I am trying to use JRE 8.
Someone know how to fix this?
I use Indigo Eclipse. Version: Service Release 2.
The problem is rt.jar in the JVM 8.0.
java.lang.CharSequence is a class under rt.jar.
rt.jar under JVM 7.0 has no problem, but rt.jar under JVM 8.0 has a problem with Eclipse Indigo. Solition is downloading Eclipse Kepler, JVM 8.0 with Kepler has no problem.
Create new workspace. Create new java project and select jvm8 as jvm. Changing the vm in an existing project is quite difficult and cached class file compiled with the previous vm can generate some strange unpredictable behavior
You need Eclipse Kepler (4.3) Service Release 2. After startup you need to install a patch that enables using Java 8 in eclipse from this update site (Help -> install new Software... -> use site):
http://download.eclipse.org/eclipse/updates/4.3-P-builds/
But a Android Project will not benefit from Java 8 because it still uses Java 6 and you cannot use Lambda Expressions or even the diamond Operator from Java 7.

How to add jdk8 in Eclipse Indigo

I just read How to have Eclipse use JDK8 to compile a project?
What i added jdk8 to eclipse as,
From the answers of How to have Eclipse use JDK8 to compile a project?
I tried to Update the JDT/Core, JDT/UI bundles from http://dist.springsource.com/snapshot/TOOLS/java8/e43
But it shows error as,
"Eclipse Java Development Tools Patch for Java 8 Support (BETA)" is not applicable to the current configuration and will not be installed.
"Eclipse Plug-in Development Environment Patch for Java 8 Support (BETA)" is not applicable to the current configuration and will not be installed.
How Can i fix it ?
I can say that Java 1.8 does in fact work with Eclipse Luna ( the beta version released around March 17, 2014) or later. I tried it and it was good.
Also, I noticed that in the Eclipse Marketplace, there are now plugins to install functionality into Kepler to support JDK1.8. I haven't tried the plugin myself though.
This is a old topic but I just wanted to point out that I have searched enough to find that Indigo version can't be updated to S.E 1.8 here the link which is given on eclipse website to update the Execution Environment but if you try it will throw error for Indigo.
Here is the link where the Information about execution environment is given.
This shows the step by step to update Execution environment.
I have tried to update Execution environment and I got the same error.

Categories