How to enable lambda expressions in Eclipse Java

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.

Lambda expressions are allowed only at source level 1.8 or above
Lambda expressions are allowed only at source level 1.8 or above

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.

Eclipse Package Explorer

Next select Java Build Path from the left list of options and then navigate to the Libraries tab.

Eclipse Java Libraries

Select JRE System Library and click Edit…

Eclipse JRE System Library

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.

Eclipse Execution Environment

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.

If you found this tutorial helpful you might enjoy my YouTube channel!