0

I'm trying to compile and run a JavaFX program/project I found online to mess around and discover JavaFX since it's the first using it in my case, from my Terminal. JavaFX isn't included in the latest JDK, so I installed openjfx

That said, I tried to compile the program with this line :

javac -cp /usr/share/java/openjfx/jre/lib/ext/jfxrt.jar *java

Which worked, all the .class files are generated, but then I tried to run it using this line :

java -cp /usr/share/java/openjfx/jre/lib/ext/jfxrt.jar:. Game

This line gave me this error :

Error : Could not find or load main class Game
Caused by : java.lang.NoClassDefFoundError: tutorialfx/tutorial23/Game (wrong name: Game)

I tried many little things so far, nothing conclusive. I started thinking that I'd be able to run any JavaFX program with the latest JDKs, but it was not the case. So here I am !

I have the latest version of openjfx, what I'm trying to do is obviously to be able to run the program !

Thank you

TierTwo
  • 123
  • 2
  • 11
  • You mention you have the latest version of OpenJFX, but the fact you're pointing to `jfxrt.jar` in your classpath seems to indicate otherwise. OpenJFX 11.0.2 (the latest stable, non-early-access release) doesn't have a `jfxrt.jar` flie; it has separate JAR files for each module (e.g. `javafx-graphics.jar`, `javafx-controls.jar`, etc.). – Slaw Feb 02 '19 at 22:37
  • @Slaw Indeed you're right, I installed it, unzipped it and done this : https://openjfx.io/openjfx-docs/#install-javafx, I can compile, but again when I try to run it, I have the exact same error I had in the original post – TierTwo Feb 02 '19 at 22:59
  • You have to run it with some packages I think. – SedJ601 Feb 03 '19 at 03:39
  • maybe `javac --module-path %PATH_TO_FX% --add-modules=javafx.controls HelloFX.java` – SedJ601 Feb 03 '19 at 03:41
  • If `Game` is the wrong name, maybe `tutorialfx.tutorial23.Game` is the right name. – trashgod Feb 03 '19 at 12:48
  • @trashgod I left the package lines even though I didn't need them. This was preventing me from running the Game. It worked without the package lines at the beginning of each files. Thanks everyone for the replies. – TierTwo Feb 03 '19 at 13:59
  • @TierTwo: Glad you got it sorted; if this is not a duplicate, please [edit] your question to include a [mcve] that shows your revised approach. – trashgod Feb 03 '19 at 16:33

0 Answers0