JavaFX application with module-info.java module not found

Answered

Hello, 

I'm trying to create an application with javaFX and Maven and everything worked well till I added the module-info.java.

Here's my module-info.java :

module IP_tracker {
requires javafx.controls;
requires pdfbox.app;
}

Now when I run my application the following error pop :

Error occurred during initialization of boot layer
java.lang.module.FindException: Module IP_tracker not found

Do you have any idea ? I've tried a lot of things such as beginning from scratch but I'm totally stuck.

Here's my pom.xml :

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

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>IP_tracker</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>

<name>IP_tracker</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>9</maven.compiler.source>
<maven.compiler.target>9</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>15.0.1</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>15.0.1</version>
</dependency>
</dependencies>

<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.5</version>
<configuration>
<compress>2</compress>
<noHeaderFiles>true</noHeaderFiles>
<stripDebug>true</stripDebug>
<noManPages>true</noManPages>
<jlinkZipName>IP_tracker</jlinkZipName>
<mainClass>IP_tracker/org.example.MainApp</mainClass>
<launcher>IP_tracker</launcher>
<jlinkImageName>IP_tracker</jlinkImageName>
</configuration>
<executions>
<execution>
<!-- Default configuration for running -->
<!-- Usage: mvn clean javafx:run -->
<id>default-cli</id>
</execution>
</executions>
</plugin>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>9</source>
<target>9</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

Thanks for your help.

1
3 comments

I see that you added the javafx-maven-plugin plugin only in pluginManagement - this will not make this plugin active. You need to add it into the build section in pom.xml.

See https://stackoverflow.com/a/53448261/2000323 and https://stackoverflow.com/a/67240739/2000323 about the error. And use the https://openjfx.io/openjfx-docs/ for steps and example projects setup to get started. Please note that all settings related to build, including module/classpath should be configured in Maven pom.xml - then IDE will automatically pick them when building/running the project.

0

This issue needs to be resolved. Every time a create a project in IntelliJ, I run into this error until i remove the module-info file. I only have this issue when trying to debug. When I compile the app and run it from the terminal, all works well. I'm using VM options. If this issue can't be fixed, at least more information should be available to solve this by the user.

1

Tim Melis please open a ticket here and attach a sample project so we can look at the issue, thank you

0

Please sign in to leave a comment.