Reputation: 4802
I checked out a Java project from SVN in Eclipse and realized that it requires Java 8 because it uses lambdas etc. I installed the Eclipse addon for Java 8 and restarted Eclipse and and have the project set up like so:
I noticed that near the bottom, it says that the default compiler compliance is 1.7, so I went into org.eclipse.jdt.core.prefs
and set the compiler compliance variable to 1.8
, as per
this answer. However, in Project -> Preferences -> Java Compiler, it still shows up as:
I have set the JRE in Project -> Java Build Path:
Yet the compiler refuses to compile lambda expressions - I get an error that looks like what I would get if I went ahead and typed it into Java 7.
This is the version of Eclipse I'm using:
Version: Kepler Service Release 1
Build id: 20130919-0819
Is the only way to solve this to install a fresh version of Eclipse or am I missing something in the configuration?
Upvotes: 35
Views: 127288
Reputation: 291
First install the JDK1.8 set to Path Open Eclipse and Open Eclipse Market Place option. Search for jdk 1.8 for kepler Install the required plugin. Restart the eclipse. Change compiler level to 1.8 from preferences. If still there is an error then click on the file and change the compiler setting explicitly to Jdk 1.8
Upvotes: 0
Reputation: 1651
I had the similar problem with eclipse kepler.I have followed these steps to resolve it
for reference, refer this link http://techno-terminal.blogspot.in/2016/05/jdk-18-compiler-compliance-is-not.html
Upvotes: 1
Reputation: 1
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
Upvotes: 0
Reputation: 2113
Old question, but posting the answer incase it helps someone. Already build path was configured to use JDK 1.2.81 However, build was failing with the error below:
lambda expressions are not supported in -source 1.5
[ERROR] (use -source 8 or higher to enable lambda expressions)
In the latest Eclipse (Photon), adding the below entry to pom.xml worked.
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>
Upvotes: 2
Reputation: 2065
Assuming you have already downloaded Jdk 1.8. You have to make sure your eclipse version supports Jdk 1.8. Click on "Help" tab and then select "Check for Updates". Try again.
Upvotes: 0
Reputation: 71
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.
Image//wiki.eclipse.org/File:ExecutionEnvironmentDescriptionInstallation.png this is the link where the Information about execution environment is given.
https://wiki.eclipse.org/JDT/Eclipse_Java_8_Support_For_Kepler This shows the step by step to update Execution environment.
I have tried to update Execution environment and I got the same error.
Upvotes: 0
Reputation: 534
It cause eclipse kepler SR1 does not support new Java™ 8 language enhancements like lambda expression.
From information here: http://www.eclipse.org/downloads/java8/
I think you should use kepler SR2 with support plugin, or change to Eclipse Luna.
Updated link 16/09/2016: https://wiki.eclipse.org/JDT/Eclipse_Java_8_Support_For_Kepler
Upvotes: 6
Reputation: 11
You must install the JDT/Eclipse Java 8 Support For Kepler. https://wiki.eclipse.org/JDT/Eclipse_Java_8_Support_For_Kepler
Upvotes: 1
Reputation: 49
I had the same problem even though I had:
a freshly downloaded JDK 1.8.0
JAVA_HOME is set
java -version on command line reports 1.8
Java in control panel is set to 1.8
downloaded Eclipse Mars
Eclipse only let me choose a compiler compliance level op to 1.7 in the compiler preferences, even though my installed JRE is 1.8.0. I also couldn't see a 1.8 in the Execution Environments underneath Installed JREs, only a JavaSE-1.7 (which I haven't even got installed!). When I clicked on that, it shows "jdk1.8.0" as a compatible JRE, so I selected that, but still no change.
Then I unzipped Eclipse Mars into a brand new directory, created a new project, and now I can select 1.8, hurrah! That greatly reduced the "Duplicate methods named spliterator..." errors I was getting when compiling my code under Java 1.8, however, there is still one left:
Duplicate default methods named spliterator with the parameters () and () are inherited from the types List and Set.
However, that's likely because I'm extending AbstractList and implementing Set, so I've fixed that for now by removing the implements Set because it doesn't really add anything in my case (other than signifying that my collection has only unique elements)
Upvotes: 4
Reputation: 8323
Two things:
First, JRE is not the same as the JDK. If you do have the JDK, you need to configure eclipse to point to that in your settings.
Second, in your screenshot above, your compiler compliance level is set to 1.7. This will treat all your code as if it's using Java 1.7. Change this to 1.8 to fix your error.
You will need to have Eclipse Luna in order to get support for Java 8, but you can add it to Kepler SR2 if you want. I'd try with Luna and the above suggestions before you go any further. See this reference.
Once you get Luna, your JAVA_HOME variable should be enough to get Eclipse to recognize JDK 8. If you want to specify an additional JDK, you can add a new Java System Library by going to:
Project -> Properties -> Java Build Path -> Libraries -> Add Library -> Java System Library
and navigating to a valid location for the JDK 8.
You can download your platform's JDK 8 here
Upvotes: 44
Reputation: 1540
First of all you should get JdK 8.
if you have Jdk installed.
you should set its path using cmd prompt or system variables.
sometimes it can happen that the path is not set due to which eclipse is unable to get the properties for jdk.
Installing latest ecipse luna can solve your problem.
i have indigo and luna. i can set 1.8 in luna but 1.7 in indigo.Eclipse luna
You can check the eclipse site. it says that the eclipse luna was certainly to associate the properties for jdk 8.
Upvotes: 1