-1

Like in the title, I'm trying to compile lambda, I'm using 1.8 jdk, and have no idea.

Error log here: enter image description here

Proof that I really got 1.8:

part1:

enter image description here

part2: enter image description here

Any ideas why I've got problem like this, lambda looks like this, but I'm sure its fine, because I'm doing code from a tutorial.

public Topic getTopic(final String id){
    topics.stream().filter(t -> t.getId().equals(id)).findFirst().get();
}

I was trying to find solution but really failed, thats why I'm writing here. ps. sorry for my bad english :)

degath
  • 1,530
  • 4
  • 31
  • 60
  • look http://stackoverflow.com/questions/22703412/java-lambda-expressions-not-supported-at-this-language-level – pedroct92 Mar 02 '17 at 22:11

1 Answers1

2

You are using a Java 8 JDK, but your project's language source level is still set to Java 6 (probably for compatibility). Therefore the JDK 8 javac is invoked in compatibility mode for Java 6 which causes it to reject your code because that uses Java 8 features. You probably want to fix the language level in your project's settings or pom.xml, and then recompile.

You can edit your pom.xml to fix this. See the Maven docs for details on how to do this, but you likely want this:

<properties>
  <maven.compiler.source>1.8</maven.compiler.source>
  <maven.compiler.target>1.8</maven.compiler.target>
</properties>
user268396
  • 11,576
  • 2
  • 31
  • 26