8

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!

Sapsadoctor
  • 91
  • 1
  • 3
  • no screenshots of text please .. instead c&p the text – kleopatra Apr 14 '21 at 09:26
  • the first thing I notice is that in properties you got java version 1.8, but you are using OpenJDK16 – Dahlin Apr 14 '21 at 15:27
  • 2
    This is a new thing in JavaFX 16—see [JDK-8256362](https://bugs.openjdk.java.net/browse/JDK-8256362). The general fix is to place the JavaFX modules on the module-path and to ensure they are resolved as modules (e.g. if your code isn't modular you may need to use `--add-modules`). Though note having JavaFX on the module-path does not require that _your code_ be modular. Unfortunately, I don't know what the fix would be while using Maven (hence a comment rather than answer). – Slaw Apr 14 '21 at 17:31
  • @Dahlin as I have mentioned in the question post the application was written via java 1.8, but now I use OpenJDK16. However, the Source/Binary Format of the app remains the same. – Sapsadoctor Apr 15 '21 at 08:00
  • @Slaw thank you for the comment, it shed some light on the situation a bit. However, since Java 1.8 doesn't support modules yet then the answer is going to be something like upgrade the Java version to 9+ or downgrade the version of JavaFX to 15-. – Sapsadoctor Apr 15 '21 at 08:31
  • If you're using Java 8 then you can't use JavaFX 9+ as those versions are compiled with a version of Java newer than Java 8 (JavaFX 11-16 are all (cross?) compiled to Java 11). But in your other comment you say you're using OpenJDK 16 which means you _are not_ using Java 8 and modules are in fact supported. Though note again, just because you have JavaFX on the module-path does not mean that _your code_ needs to be modular. – Slaw Apr 16 '21 at 01:29
  • You could also just igore this warning. It is not harmful. – mipa Apr 25 '21 at 12:59
  • Important Changes JavaFX runtime logs a warning if javafx.* modules are loaded from the classpath https://github.com/openjdk/jfx/blob/master/doc-files/release-notes-16.md – Gunnar Bernstein May 09 '21 at 15:22
  • @GunnarBernstein so How to fix this warning? – Jawad El Fou May 10 '21 at 18:34
  • @Jawad El Fou: I gave up. Tried answer of SANISH, but this did not change a thing. The bug thread was not to helpful either. I switched back to JavaFX 15. – Gunnar Bernstein May 11 '21 at 15:41
  • @GunnarBernstein I am going to that I guess, its a shame – Jawad El Fou May 11 '21 at 17:03

2 Answers2

0
    // 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',
                ]
            }
        }
SANISH
  • 1
  • 1
  • 5
    Code only answers are discouraged. Please provide a summary of how your answer solves the problem and why it may be preferable to the other answers provided. – DaveL17 Apr 25 '21 at 12:02
0

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.)

Mike Nakis
  • 56,297
  • 11
  • 110
  • 142