I am trying to follow the spark java tutorial. I set up all things, and tried compiling the project. I got the following error:
Error:(8, 34) java: lambda expressions are not supported in -source 1.5
(use -source 8 or higher to enable lambda expressions)
I then tried setting the compiler options and the default JDK, but I am still seeing that error.
Here is how I set my IDE:
I would be happy if you could help me.
Lambda Expressions were added in Java 8. A lambda expression is a short block of code which takes in parameters and returns a value. Lambda expressions are similar to methods, but they do not need a name and they can be implemented right in the body of a method.
Based on the syntax rules just shown, which of the following are not valid lambda expressions? Answer: Only 4 and 5 are invalid lambdas.
It's not enough to set the project level. You need to set up the Module level.
Follow these steps.
Right Click on the project------>> go to Open module Settings---> In that opening window click the Project in project settings----> and set project SDK
See this answer https://stackoverflow.com/a/21747364/492620
Select project and press alt+ctrl+shift+s
and you get Project Structure window where you need to set project sdk and language level for project.
Then you should be able to use lambdas.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With