0

I am using openjfx 11 with java 11.

If I launch the app with mvn, it works fine. I have those dependencies added:

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

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

But if I run within Intellij Idea (2018.2), it gives me:

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

IntelliJ idea adds the jars to classpath.

José Pereda
  • 44,311
  • 7
  • 104
  • 132
Thiago Sayão
  • 2,197
  • 3
  • 27
  • 41
  • See this [question](https://stackoverflow.com/questions/52467561/intellij-cant-recognize-javafx-11-with-openjdk-11/52470141#52470141) on how to set IntelliJ and the Maven project – José Pereda Oct 09 '18 at 20:50
  • I saw the answer but it does not address running the app from intellij without manually setting a separated (from maven) sdk folder. – Thiago Sayão Oct 09 '18 at 23:36
  • Yes it does, via adding the required maven plugins to your pom. Then you can run the `exec:java` goal (see bullet points 4, 5). – José Pereda Oct 09 '18 at 23:41
  • But running the maven goal is not the same as running through intellij idea. Or is it? Can I debug running like this? – Thiago Sayão Oct 09 '18 at 23:45
  • Yes, you can run and debug from IntelliJ through the Maven Projects window. – José Pereda Oct 09 '18 at 23:47

2 Answers2

1

For anyone looking, I have found the answer here (not specific to Intellij) : http://mail.openjdk.java.net/pipermail/openjfx-dev/2018-October/022675.html

Thiago Sayão
  • 2,197
  • 3
  • 27
  • 41
1

There are 2 ways:


The first one is to pass
--module-path=PATHTOOPENJFX/lib --add-modules=javafx.controls,javafx.fxml
arguments to java


The second one:
Create new class, make it main and call main() of the class that extends Application

package sample;
    public class Main {
        public static void main(String[] args) {
            YourClass.main(args);
        }
    }