Home > Mobile >  Warning with javafx-maven-plugin version >= 0.0.5: "Module name not found in <mainClass&g
Warning with javafx-maven-plugin version >= 0.0.5: "Module name not found in <mainClass&g

Time:12-28

While updating JavaFX projects to version 17.0.1, a new warning message is being issued by any version of the javafx-maven-plugin with a version number of 0.0.5 or greater.

The warning message is:

Module name not found in <mainClass>. Module name will be assumed from module-info.java

Steps to Reproduce

In any convenient directory, execute the following command to create a new JavaFX project:

mvn archetype:generate \
        -DarchetypeGroupId=org.openjfx \
        -DarchetypeArtifactId=javafx-archetype-simple \
        -DarchetypeVersion=0.0.3 \
        -DgroupId=org.openjfx \
        -DartifactId=example \
        -Dversion=1.0.0 \
        -Djavafx-version=17.0.1

After the project is created, cd into the example directory and run:

mvn clean javafx:run

On my system, a window opens and displays the text:

Hello, JavaFX 17.0.1, running on Java 17.0.1.

That is as expected. The pom.xml file in the project directory uses version 0.0.3 of the plugin. The relevant region of pom.xml looks like:

...
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.3</version>
                <configuration>
                    <mainClass>org.openjfx.App</mainClass>
                </configuration>
            </plugin>
...            

Change to a more recent version of the plugin (The current version is 0.0.8.) and re-run the program. On my system, the program still operates as expected but produces the warning message.

Using a more recent version of the project archetype (e.g. -DarchetypeVersion=0.0.6 \) produces the warning at once since it creates a project that uses the updated plugin.

Checking the Source of the Plugin

Checking the source of the plugin at https://github.com/openjfx/javafx-maven-plugin reveals that a change was made to the file JavaFXBaseMojo.java. A new function was added in version 0.0.5 and later called createMainClassString that displays the error.

Some System Info

mvn -version
Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Maven home: /usr/local/Cellar/maven/3.8.4/libexec
Java version: 17.0.1, vendor: Homebrew, runtime: /usr/local/Cellar/openjdk/17.0.1_1/libexec/openjdk.jdk/Contents/Home
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "12.1", arch: "x86_64", family: "Mac"

I don't see any problem with the project or POM. What do I need to do to eliminate the warning?

CodePudding user response:

I recently encountered the same problem here:

When executing the command mvn javafx:run, the javafx-maven-plugin produces the following: [WARNING] Module name not found in <mainClass>. Module name will be assumed from module-info.java. The mainClass configuration attribute is the "fully qualified name, with or without module name." While the warning can be safely ignored, adding the module name eliminates the warning:

-  <mainClass>org.jfree.chart3d.fx.demo.OrsonChartsFXDemo</mainClass>
   <mainClass>org.jfree.fx.demos/org.jfree.chart3d.fx.demo.OrsonChartsFXDemo</main

Using your example, the following configuration eliminates the warning:

<configuration>
   <mainClass>org.openjfx/org.openjfx.App</mainClass>
</configuration>
  • Related