I am using Eclipse IDE for Java Developers, Kepler Service Release 2, with jdk1.8.0 installed as the JRE.
I am using Java All-in-one For Dummies to learn Java SE 8, and, when writing a program, using Swing, I am getting this error: syntax error on token "-", -- expected
With this code:
button1 = new JButton("Click me!");
button1.addActionListener(e -> button1Click() );
panel1.add(button1);
exitButton = new JButton("Exit");
exitButton.addActionListener(e -> exitButtonClick() );
panel1.add(exitButton);
this.add(panel1);
button1 and exitButton have been declared as JButtons already, and I have imported javax.swing.* and java.awt.event.*.
How can I fix this?
if you are on kepler install this update : http://wiki.eclipse.org/JDT/Eclipse_Java_8_Support_For_Kepler
and then set
windows > preferences > java > compiler > compiler compliance level > 1.8
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