Home >Java >javaTutorial >How to Resolve the \'Unsupported JavaFX Configuration: Classes were loaded from \'unnamed module @...\'\' Warning?

How to Resolve the \'Unsupported JavaFX Configuration: Classes were loaded from \'unnamed module @...\'\' Warning?

Susan Sarandon
Susan SarandonOriginal
2024-10-30 02:31:02669browse

 How to Resolve the

JavaFX: Unresolved Module Path for Classes

Problem:

Upon running a JavaFX application, a warning is displayed: "Unsupported JavaFX configuration: classes were loaded from 'unnamed module @...'"

Background:

With the introduction of Java 9's Platform Module System, JavaFX modules must be loaded as "named modules" rather than "unnamed modules." This warning indicates that JavaFX is being loaded incorrectly.

Solution:

Non-Modular Application:

<code class="java">java --module-path <path-to-fx> --add-modules javafx.controls ...</code>

Modular Application:

<code class="java">java --module-path <path> --module app/com.example.app.Main [args...]</code>

In the above commands, replace with the location of JavaFX modules and with the path to the JavaFX JAR or modules.

Use JDK Distribution with JavaFX:

Install a JDK distribution that includes JavaFX, such as:

  • BellSoft Liberica JDK (Full JDK)
  • Azul Zulu JDK (JDK FX)

Ignore the Warning:

Although not recommended, you can choose to ignore the warning as it doesn't currently break any functionality in JavaFX 21. However, JavaFX may not be loaded correctly.

Main Class Restriction:

Note that when JavaFX is loaded from the unnamed module, the main class cannot extend javafx.application.Application. A separate main class is required to launch the JavaFX application.

Deployment Options:

  • Require Client JRE with JavaFX: Ensure clients have a JRE with JavaFX installed.
  • Self-Contained Application: Create an executable containing all dependencies, including the JRE. This method may introduce issues with cross-platform compatibility.
  • Executable "Fat" JAR File: Package all dependencies into a JAR file. This approach is unsupported but may provide convenience.

The above is the detailed content of How to Resolve the \'Unsupported JavaFX Configuration: Classes were loaded from \'unnamed module @...\'\' Warning?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn