1

I have a Maven project in Eclipse which uses JFX11. My pom has this dependency:

<dependency>
  <groupId>org.openjfx</groupId>
  <artifactId>javafx-controls</artifactId>
  <version>11</version>
</dependency>

It compiles but when running I get

Error: JavaFX runtime components are missing, and are required to run this application

Do I need to include another dependency as well?

leyren
  • 524
  • 6
  • 20
  • Duplicated of [this question](https://stackoverflow.com/questions/52144931/how-to-add-javafx-runtime-to-eclipse-in-java-11) – José Pereda Jan 17 '19 at 17:52
  • 1
    I don't understand why I need to separately reference it again in the VM options if I already have it as dependency laying around. Is there no way around that? Same problem when actually packing it as a JAR. – leyren Jan 17 '19 at 20:01
  • I'd suggest you have a look at the docs https://openjfx.io/openjfx-docs/#IDE-Eclipse. When you use Maven `exec:java` you don't need VM options. But you do if you run `java` or Maven `exec:exec`. See also [this](https://stackoverflow.com/questions/52741129/different-behaviour-between-maven-eclipse-to-launch-a-javafx-11-app/52743896#52743896) and [this](https://stackoverflow.com/questions/52653836/maven-shade-javafx-runtime-components-are-missing/52654791#52654791). – José Pereda Jan 17 '19 at 20:09
  • Thank you. Although I still don't really see why I seem to need to specify the needed jfx modules like so: java --module-path $PATH_TO_FX --add-modules=javafx.controls HelloFX I mean, shouldn't it be possible to include the javafx library in my classpath to automatically search for needed modules there? Either having to manually specify it or packaging it as fat jar even though I have the library present on my system both sound like pretty ugly solutions. – leyren Jan 18 '19 at 10:56
  • You need to understand how modules work. The JavaFX jars are modules, and these are not included in your JDK anymore. So like any other third party modular dependency, you will have to include it in the vm options. – José Pereda Jan 18 '19 at 11:03
  • Possible duplicate of [How to add JavaFX runtime to Eclipse in Java 11?](https://stackoverflow.com/questions/52144931/how-to-add-javafx-runtime-to-eclipse-in-java-11) – Bobulous Jan 19 '19 at 19:51

0 Answers0