0

I wrote a game built on JavaFX using Eclipse. When running the game from Eclipse, it runs perfectly. However, when I try and run it from the CMD, I get compile errors like:

Game.java:146: error: ';' expected
                close.setOnAction(e -> window.close());
                                     ^
Game.java:146: error: <identifier> expected
                close.setOnAction(e -> window.close());
                                                   ^
Game.java:146: error: ';' expected
                close.setOnAction(e -> window.close());
                                                     ^
Game.java:150: error: <identifier> expected
                StartLayout.setId("pane");

Could this be a problem with the JavaFX installation? ideas?

4
  • Place full javac command with you try to compile Commented Jun 25, 2017 at 21:48
  • Sorry, I didn't understand what you mean. I'm trying to run javac *.java and it's like not recognizing JavaFX code Commented Jun 25, 2017 at 21:51
  • Lambda expressions (e -> window.close()) require java 8 (javac 1.8+ to compile). From your comment on the answer, it seems that you are using javac 1.7. Commented Jun 25, 2017 at 22:04
  • how do you think I can fix that? I already downloaded the latest version of JDK Commented Jun 25, 2017 at 22:05

1 Answer 1

3

What is your java version? If u wanna use lambda expression, then you need java 8. Open cmd and check ur java version. Write this on cmd line:

java -version

On Eclipse Windows - Preferences - Java - Installed Jre.

Sign up to request clarification or add additional context in comments.

3 Comments

it gives me javac 1.7.0_67 but the main one is java version "1.8.0_131"
Thank you! I solved the problem. I apparently once installed some Java packages from a coursera course on Data structures which had a previous version of javac. I edited the path and everything works out.
Open cmd line. Copy this: rundll32 sysdm.cpl,EditEnvironmentVariables. Then envoriment variables will be open. Check JAVA_HOME and JRE_HOME variable path.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.