13

I am using NetBeans 8. When my code contains a Lambda expression and I try to compile, I get the following error message:

lambda expression not expected here

lambda expressions are not supported in -source 1.5
  (use -source 8 or higher to enable lambda expressions)
----
(Alt-Enter shows hints)
Iain Ballard
  • 4,433
  • 34
  • 39
Pushkar
  • 727
  • 1
  • 7
  • 21

4 Answers4

26

Please click right from you project -> Properties -> Choose Sources -> (you will see Source/Binary Format) change it to 1.8 -> Click OK.

Or you can see in this link http://tinadev.blogspot.com/2015/08/lambda-expression-not-expected-here.html

Thanks

For NetBeans IDE 8.2, JDK 8

Zeeng
  • 1,155
  • 9
  • 13
Tien Nguyen
  • 449
  • 8
  • 13
6

Change compiler version of your source code into your project properties to jdk 8 and firstly check whether you have installed one.

skiwi
  • 66,971
  • 31
  • 131
  • 216
RMachnik
  • 3,598
  • 1
  • 34
  • 51
  • Thanks. Your right, In Net Beans I am using 8 only but by default Compiler or Source/Binary format was 1.5 only. Now i have changed to 1.8, It's working now – Pushkar Mar 27 '14 at 11:38
  • 1
    @Pushkar can you explain where you changed this? – tier1 Nov 06 '14 at 17:06
  • 5
    @tier1 In menu follow path Menu >> Properties >> Java Compiler here I have made changes. – Pushkar Nov 10 '14 at 07:28
4

In the project properties dialog, select Sources in the left panel and then on the bottom right look for "Source/Binary Format" Change that to JDK 8.

0

Download JDK 1.8 to resolve this issue. change the JAVA_HOME environment variables path to jdk_1.8. Right Click on the project folder which has the above mentioned compilation error and select properties. In Sources tab change the source/binary format to JDK 8. In libraries change Java Platform to JDK 1.8.

Vignan Sankati
  • 380
  • 5
  • 15