1

I use IntelliJ with open-sdk 11.0.12. I have projekt based on maven. I started with empty project and added some dependencies. I'm in the middle of creating JavaFX application.

My pom.xml file looks like this:

<?xml version="1.0" encoding="UTF-8"?>

4.0.0

<groupId>org.example</groupId>
<artifactId>kalkulator</artifactId>
<version>1.0-SNAPSHOT</version>

<build>
    <plugins>
        <plugin>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-maven-plugin</artifactId>
            <version>0.0.8</version>
            <executions>
                <execution>
                    <id>run</id>
                    <configuration>
                        <mainClass>project.Main</mainClass>
                    </configuration>
                </execution>
                <execution>
                    <id>debug</id>
                    <configuration>
                        <mainClass>project.Main</mainClass>
                        <options>
                            <option>-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:8000</option>
                        </options>
                    </configuration>
                </execution>
            </executions>
            <configuration>
                <mainClass>${project.mainClass}</mainClass>
            </configuration>
        </plugin>
    </plugins>
</build>

<dependencies>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>5.1.0</version>
        <scope>test</scope>
    </dependency>
    <!-- JavaFX -->
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-controls</artifactId>
        <version>17</version>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-fxml</artifactId>
        <version>17</version>
    </dependency>
    <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-client</artifactId>
        <version>5.0.0.Final</version>
    </dependency>
</dependencies>

<properties>
    <project.mainClass>me.noname.calculator.Calculator</project.mainClass>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
</properties>

When I run it with maven it works fine. I have set goal: clean javafx:run. I would like to run this project local in intellij, but the error shows:

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

I tried to make module file, but then it shows that the javafx.application.Application is missing. Which is strange because I have it from dependency. What should I do so I can use local debugger on this code?

Krs1232
  • 51
  • 5

1 Answers1

3

I resolved my problem by creating a new JavaFX project in IntelliJ. I still depend on maven. That was the fastest way. But I still would like to know why it was not working from the empty maven project and what was the difference.

ouflak
  • 2,458
  • 10
  • 44
  • 49
Krs1232
  • 51
  • 5
  • I have done the same, giving up on a project gone bad and then restarting with a fresh new project while moving over contents from old. I’ve done that not for JavaFX but for other kinds of projects. Between the IDEs and Maven, things seem to occasionally get ruined for mysterious reasons. Another desperate solution in similar circumstances is to delete the `.m2` folder where Maven caches its copies of libraries downloaded from the Internet. Maven will automatically recreate this folder, and repopulate it (which can take a while). Also, your IDE may offer a *Invalidate caches* feature. – Basil Bourque Dec 14 '21 at 22:13
  • I couldn't tell you why your old project failed, there is not enough information provided to be able to diagnose that. – jewelsea Dec 14 '21 at 22:18