1

I am on a Linux machine and am trying to get a javaFX app to run but I am stuck. I keep getting the error in the title. IntelliJ is running the following command before the error:

/usr/lib/jvm/java-17-openjdk-amd64/bin/java -javaagent:/opt/IntelliJ/lib/idea_rt.jar=38753:/opt/IntelliJ/bin -Dfile.encoding=UTF-8 -classpath /home/j3rk/IdeaProjects/C195/out/production/C195:/home/j3rk/.m2/repository/mysql/mysql-connector-java/8.0.27/mysql-connector-java-8.0.27.jar:/home/j3rk/.m2/repository/com/google/protobuf/protobuf-java/3.11.4/protobuf-java-3.11.4.jar:/home/j3rk/.m2/repository/org/openjfx/javafx-base/12-ea+6/javafx-base-12-ea+6.jar:/home/j3rk/.m2/repository/org/openjfx/javafx-base/12-ea+6/javafx-base-12-ea+6-linux.jar:/home/j3rk/.m2/repository/org/openjfx/javafx-controls/11/javafx-controls-11.jar:/home/j3rk/.m2/repository/org/openjfx/javafx-controls/11/javafx-controls-11-linux.jar:/home/j3rk/.m2/repository/org/openjfx/javafx-graphics/11/javafx-graphics-11.jar:/home/j3rk/.m2/repository/org/openjfx/javafx-graphics/11/javafx-graphics-11-linux.jar:/home/j3rk/.m2/repository/org/openjfx/javafx-base/11/javafx-base-11.jar:/home/j3rk/.m2/repository/org/openjfx/javafx-base/11/javafx-base-11-linux.jar:/home/j3rk/.m2/repository/org/openjfx/javafx-fxml/11/javafx-fxml-11.jar:/home/j3rk/.m2/repository/org/openjfx/javafx-fxml/11/javafx-fxml-11-linux.jar sample.Main

As you can see, I have tried adding the openjfx dependencies via maven and it still does not work.

I have tried the solution found in: Error: JavaFX runtime components are missing - JavaFX 11 and OpenJDK 11 and Eclipse IDE

Two other javaFX projects are loading fine on the same machine, but for some reason, this particular project keeps giving me the same error no matter what I try.

Screenshot of my modules/dependencies

Let me know if you need more information. Any help would be appreciated.

Angel D.
  • 11
  • 1
  • 2
    And this is why Swing won't die. Ok, have a look at [Getting Started with JavaFX](https://openjfx.io/openjfx-docs/) - look at the sections on Maven and IntelliJ. [IntelliJ IDEA and JavaFX](https://blog.jetbrains.com/idea/2021/01/intellij-idea-and-javafx/) ... might confuse you. [Create a new JavaFX project](https://www.jetbrains.com/help/idea/javafx.html); [Step by step guide on how to set up JavaFX on IntelliJ](https://intellij-support.jetbrains.com/hc/en-us/community/posts/360008218979-IDEA-unable-to-run-JavaFX-Maven-project) – MadProgrammer Feb 18 '22 at 03:00
  • 2
    [How To Effortlessly Setup JavaFX With Maven (+ debugging tips!) in IntelliJ](https://edencoding.com/javafx-maven/). The important note(s) is JavaFX is a seperate module and needs to be downloaded separately from the JDK/JRE, this is where Maven can help, but you may need to include additional parameters on the command line, as it not only needs the .jar files, but also the platform library files. I don't use IntelliJ and it's taken way longer then it should to get it to work in Netbeans – MadProgrammer Feb 18 '22 at 03:01
  • Update to the most recent version of Idea, create a [new JavaFX project](https://www.jetbrains.com/help/idea/javafx.html) using the wizard, test it works, then copy in code from your existing project. For any dependencies you add in maven, also require them in your module-info. Or, for a non-modular project, delete the module-info and use a JDK such as liberica that includes JavaFX. Those are IMO *by far* the easiest ways to deal with these setup errors. – jewelsea Feb 18 '22 at 04:12
  • 1
    Thank you MadProgrammer for your responses. I ended up doing what @jewelsea suggested and FINALLY got it to work. I still have no clue what I was doing wrong in the first place but am thankful that it is now working. – Angel D. Feb 19 '22 at 05:24
  • 1
    @parsecer It's the motivation (and demonstration) of want to seperate the "extended" functionality of JavaFX from the core API (many people would like to see AWT and Swing pulled out as well). I've tried several ways to get JavaFX to work and Maven is (mostly) the only solution that works . But yes, it could have been made SOOO much easier – MadProgrammer Nov 13 '22 at 21:15

1 Answers1

0

This video helped: https://www.youtube.com/watch?v=ZfaPMLdgJxQ&ab_channel=BoostMyTool

In particular what I did was:

  1. Download the SDK from this website: https://gluonhq.com/products/javafx/
  2. In Idea Intelij (in the Run menu) Edit Configurations -> add VM options:
--module-path /path-to-sdk/lib/ --add-modules javafx.controls,javafx.fxml

And finally it worked!

parsecer
  • 4,758
  • 13
  • 71
  • 140