JavaFX16 WARNING: Unsupported JavaFX configuration: classes were loaded from 'unnamed module @***'

Viewed 5258

I am trying to run JavaFX16 Application using OpenJDK16 (the application itself was written via Java 1.8). Unfortunately, every time running my application I receive the following WARNING message:

--- exec-maven-plugin:3.0.0:exec (default-cli) @ ListPlanWizard --- апр. 14, 2021 12:46:53 PM com.sun.javafx.application.PlatformImpl startup WARNING: Unsupported JavaFX configuration: classes were loaded from 'unnamed module @1cebc698'

Could you explain why I'm getting it and how can I avoid this, please?

  • Please note, that unlike the other issues with this or similar warnings which I've found in the Internet my application doesn't crash after this or something and works as intended.

  • Also please note that I use the hint from this question to avoid Error: JavaFX runtime components are missing, and are required to run this application

  • I don't use external JavaFX OpenSDK or something in my project's properties.

My pom.xml document is attached below:

<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>bla.blabla</groupId>
    <artifactId>ListPlanWizard</artifactId>
    <version>0.9.3</version>
    <packaging>jar</packaging>

    <name>ListPlanWizard</name>
    <description>blablablablabla</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <start-class>bla.blabla.ListPlanWizard.Crutch</start-class>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency> 
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>mssql-jdbc</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- Used to work with the older excel file format - .xls -->
        <!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.17</version>
        </dependency>
        <!-- Used to work with the newer excel file format - .xlsx -->
        <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>3.17</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>16</version>
        </dependency>
        <dependency>
            <groupId>com.github.ulisesbocchio</groupId>
            <artifactId>jasypt-spring-boot-starter</artifactId>
            <version>2.0.0</version>
        </dependency>
        
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.6</version>
                <configuration>
                    <mainClass>bla.blabla.ListPlanWizard.Crutch</mainClass>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <executable>java</executable>
                    <compilerArguments>
                        <excludeDevtools>true</excludeDevtools>
                    </compilerArguments>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

Thank you for the answers in advance!

2 Answers
    // For Gradle .... 
   // Add the code in your 'build.gradle'.
   // Javafx modules will be fetched from classpath...
  // No warnings thereafter..
    run   {
            doFirst   {
                jvmArgs   =   [
                        '--module-path', classpath.asPath,
                        '--add-modules', 'javafx.controls',
                        '--add-modules', 'javafx.fxml',
                        '--add-modules', 'javafx.graphics',
                        '--add-modules', 'javafx.base',
                        '--add-modules', 'javafx.swing',
                ]
            }
        }

Here are the magical incantations that fixed the problem for me:

  • I have not downloaded any javafx SDK.
  • I do not use javafx-maven-plugin.
  • I use only two javafx modules: javafx.swing and javafx.web.
  • These two modules need the following additional modules: javafx-controls, javafx-media, javafx-graphics, and javafx-basic.
  • I include javafx.swing and javafx.web as plain maven dependencies, as follows:

(in pom.xml)

    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-web</artifactId>
        <version>19-ea+3</version>
    </dependency>

    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-swing</artifactId>
        <version>19-ea+3</version>
    </dependency>

Then, I run my app with the following JVM arguments:

--add-modules=javafx.swing,javafx.web --module-path=$MAVEN_REPOSITORY$\org\openjfx\javafx-web\19-ea+3\javafx-web-19-ea+3.jar;$MAVEN_REPOSITORY$\org\openjfx\javafx-web\19-ea+3\javafx-web-19-ea+3-win.jar;$MAVEN_REPOSITORY$\org\openjfx\javafx-controls\19-ea+3\javafx-controls-19-ea+3.jar;$MAVEN_REPOSITORY$\org\openjfx\javafx-controls\19-ea+3\javafx-controls-19-ea+3-win.jar;$MAVEN_REPOSITORY$\org\openjfx\javafx-media\19-ea+3\javafx-media-19-ea+3.jar;$MAVEN_REPOSITORY$\org\openjfx\javafx-media\19-ea+3\javafx-media-19-ea+3-win.jar;$MAVEN_REPOSITORY$\org\openjfx\javafx-swing\19-ea+3\javafx-swing-19-ea+3.jar;$MAVEN_REPOSITORY$\org\openjfx\javafx-swing\19-ea+3\javafx-swing-19-ea+3-win.jar;$MAVEN_REPOSITORY$\org\openjfx\javafx-graphics\19-ea+3\javafx-graphics-19-ea+3.jar;$MAVEN_REPOSITORY$\org\openjfx\javafx-graphics\19-ea+3\javafx-graphics-19-ea+3-win.jar;$MAVEN_REPOSITORY$\org\openjfx\javafx-base\19-ea+3\javafx-base-19-ea+3.jar;$MAVEN_REPOSITORY$\org\openjfx\javafx-base\19-ea+3\javafx-base-19-ea+3-win.jar

(Note that '$MAVEN_REPOSITORY$' is a macro provided by IntellijIdea for convenience. It expands to something like ~/.m2/repository.)

Related