Java 使用 NetBeans 8 但遇到 Lambda 表达式的编译错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22686174/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using NetBeans 8 but getting below compilation error for Lambda expression
提问by Pushkar
I am using NetBeans 8. When my code contains a Lambda expression and I try to compile, I get the following error message:
我正在使用 NetBeans 8。当我的代码包含 Lambda 表达式并尝试编译时,我收到以下错误消息:
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)
采纳答案by RMachnik
Change compiler version of your source code into your project properties to jdk 8 and firstly check whether you have installed one.
将源代码的编译器版本更改为项目属性为 jdk 8 并首先检查您是否安装了一个。
回答by Richard Bailey
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.
在项目属性对话框中,选择左侧面板中的 Sources,然后在右下角查找“Source/Binary Format”,将其更改为 JDK 8。
回答by Tien Nguyen
Please click right from you project -> Properties -> Choose Sources -> (you will see Source/Binary Format) change it to 1.8 -> Click OK.
请从您的项目中单击右键 -> 属性 -> 选择源 ->(您将看到源/二进制格式)将其更改为 1.8 -> 单击确定。
Or you can see in this link http://tinadev.blogspot.com/2015/08/lambda-expression-not-expected-here.html
或者您可以在此链接中看到http://tinadev.blogspot.com/2015/08/lambda-expression-not-expected-here.html
Thanks
谢谢
回答by Vignan S
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.
下载 JDK 1.8 以解决此问题。将 JAVA_HOME 环境变量路径更改为 jdk_1.8。右键单击具有上述编译错误的项目文件夹并选择属性。在 Sources 选项卡中,将源代码/二进制格式更改为 JDK 8。在库中,将 Java Platform 更改为 JDK 1.8。