This page will show you a step by step tutorial on how to enable lambda expressions for Java in Eclipse. You may have found this page if you’ve received an error similar to the one shown below.
The reason this is occurring is due to the fact that Eclipse will sometimes choose a default JRE version for your projects that is an earlier version than the latest release. There are benefits to writing code that is compatible with previous versions, such as supporting a wider potential user base, but in most cases it is fine to update to the latest version. In this case, it is the only way to enable lamda expressions for Java.
First you’ll want to right-click your project name in the Package Explorer and select Properties.
Next select Java Build Path from the left list of options and then navigate to the Libraries tab.
Select JRE System Library and click Edit…
Select the Execution Environment drop-down list and choose JavaSE-1.8. Or, if you have a more recent version of Java than 1,8, feel free to choose that.
And you’re finished! You should no longer receive errors for attempting to use lambda expressions in your program! If you are still experiencing issues, restarting Eclipse may remove any residual erroneous error messages.