Ombrelin
Ombrelin

Reputation: 667

OpenJFX 14 with maven and IntelliJ : Cannot run application

I am trying to use OpenJFX on a JDK 14 Java project on IntelliJ. My project has multiple IntelliJ modules that each have a pom.xml.

In the IntelliJ Module that contains my main I have added JFX as dependency :

<dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-controls</artifactId>
    <version>14</version>
    <type>pom</type>
</dependency>

And in my top-level pom.xml I have added the JFX plugin :

<plugin>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-maven-plugin</artifactId>
    <version>0.0.4</version>
    <configuration>
        <mainClass>fr.efrei.wiemetarsene.caspersky.app.Main</mainClass>
    </configuration>
</plugin>

But when I try to run my app with :

mvn javafx:run

Il get the following error :

[ERROR] Failed to execute goal org.openjfx:javafx-maven-plugin:0.0.4:run (default-cli) on project caspersky: Error: Output directory is empty, compile first -> [Help 1]

I tried to run :

mvn compiler:compile

before doing that but the result is exactly the same. Do you have any clue about why it's not working?

Upvotes: 1

Views: 1823

Answers (2)

Agata Kobusinska
Agata Kobusinska

Reputation: 138

I have multi module javafx project and I met the same error. Main class is in my View module. In pom file I have:

<plugin>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-maven-plugin</artifactId>
    <version>0.0.5</version>
    <configuration>
        <source>14</source>
        <target>14</target>
        <release>14</release>
        <mainClass>Main</mainClass>
    </configuration>
</plugin>

then in terminal type:

mvn install
cd View
mvn javafx:run

After making some changes in my code I often receive some strange errors like missing components. Then repeating above steps is fixing the problem.

Upvotes: 2

Naman
Naman

Reputation: 31868

From there README, you can try out the following changes:

<plugin>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-maven-plugin</artifactId>
    <version>0.0.4</version>
    <configuration>
        <source>14</source>
        <target>14</target>
        <release>14</release>
        <mainClass>fr.efrei.wiemetarsene.caspersky.app.Main</mainClass>
    </configuration>
</plugin>

and further, compile your project using

mvn javafx:compile

but since the docs might be outdated, you can try executing

mvn compile

or

mvn clean javafx:jlink

Upvotes: 1

Related Questions