0

I have come into an unusual problem. I've submitted my code for grading and it seems that when my professor compiles/run my Java program it wont run on her computer. I've tried on both windows and Mac machine and it runs and compiles just fine. I am guessing this issue is due to an outdated JDK. If you want the whole code of my project (which is kind of long) I can provide that. She's getting the following error:

Program.java:16: illegal start of expression
         SwingUtilities.invokeLater(() -> {

I believe this error is due to Syntax, but when I run this in multiple IDEs on multiple OS's it never shows up that error. She's running the exact same thing as I am.

  • 2
    She probably needs to upgrade her version of java to jave 8 – smac89 Mar 17 '15 at 23:09
  • 1
    Just use the pre-Java-8 syntax for this. `SwingUtilities.invokeLater(new Runnable() {....})` – Hovercraft Full Of Eels Mar 17 '15 at 23:09
  • Was there anything in your assignment spec which specified the Java version you could use? If not then you could ask her to upgrade to Java 8. Otherwise you'll need to rebuild it for Java 7 as @HovercraftFullOfEels suggested. – deyur Mar 17 '15 at 23:17
  • Thank you so much for you assistance, so the line of code that apparently causes this issue is this one SwingUtilities.invokeLater(()-> { I get this error when I replace that by your code: Program.java:16: error: is not abstract and does not override abstract method run() in Runnable SwingUtilities.invokeLater(new Runnable(){ – Juan Rojas Mar 17 '15 at 23:18
  • As the error says, you need to override the `run()` method in order to implement the `Runnable` interface, and put your actual functionality inside the `run()` method. See example [here](http://docs.oracle.com/javase/tutorial/essential/concurrency/runthread.html), for example, plus the [javadoc](https://docs.oracle.com/javase/8/docs/api/java/lang/Runnable.html). @HovercraftFullOfEels was just giving you an outline of the required approach. – DNA Mar 17 '15 at 23:22
  • Problem fixed! Thank you all for the assistance. – Juan Rojas Mar 17 '15 at 23:26

0 Answers0