How do I use Lambdas in Codename one in Eclipse?

12 views
Skip to first unread message

hvri...@gmail.com

unread,
Jul 23, 2016, 4:35:47 PM7/23/16
to CodenameOne Discussions
I am using Eclipse Mars. The JRE for Eclipse I am using is Oracle's Java 8 /usr/lib/jvm/java-8-oracle/jre and I have set the compiler compliance to 1.8 for the project and for Eclipse. However, when I try to write a lambda, for example:
textField.addActionListener(evt -> Dialog.show("Title", "Body", "OK", "Cancel"));

The build fails with       
[javac] /home/hvrigazov/Assistant/mobile/assistant/src/com/cognit/assistant/Assistant.java:43: error: illegal start of expression
[javac]         textField.addActionListener(evt -> Dialog.show("Title", "Body", "OK", "Cancel"));

Shai Almog

unread,
Jul 24, 2016, 12:11:52 AM7/24/16
to CodenameOne Discussions, hvri...@gmail.com
You need to use the JDK and not the JRE.
You need to make sure you created a Java 8 Codename One project and not a Java 5 project.
Reply all
Reply to author
Forward
0 new messages