D
D
devpy142021-08-24 17:33:27
Java
devpy14, 2021-08-24 17:33:27

Unsupported JavaFX configuration: classes were loaded from 'unnamed module @121464c3' error when running jar file?

When running the jar file via cmd, it gives the following error:

WARNING: Unsupported JavaFX configuration: classes were loaded from 'unnamed module @121464c3'
Exception in Application start method
Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
        at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
        at java.base/java.lang.Thread.run(Thread.java:831)
Caused by: javafx.fxml.LoadException:
file:/C:/Users/user/Desktop/MP3Player.jar!/resources/FXML/homePage.fxml:15

        at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2707)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2685)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3323)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3280)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3249)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3222)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3199)
        at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3192)
        at main.Main.start(Main.java:18)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
        at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:474)
        at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:447)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
        at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:446)
        at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
        at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
        ... 1 more
Caused by: java.lang.IllegalArgumentException: Invalid URL: Invalid URL or resource not found
        at javafx.scene.image.Image.validateUrl(Image.java:1125)
        at javafx.scene.image.Image.<init>(Image.java:618)
        at main.HomePageController.<init>(HomePageController.java:56)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:78)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
        at java.base/java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:128)
        at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:350)
        at java.base/java.lang.Class.newInstance(Class.java:642)
        at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:938)
        at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.java:982)
        at javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:229)
        at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:754)
        at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2808)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2634)
        ... 17 more
Caused by: java.lang.IllegalArgumentException: Invalid URL or resource not found
        at javafx.scene.image.Image.validateUrl(Image.java:1117)
        ... 32 more

C:\Users\user\Desktop>java -jar MP3Player.jar
рту. 24, 2021 8:18:03 PM com.sun.javafx.application.PlatformImpl startup
WARNING: Unsupported JavaFX configuration: classes were loaded from 'unnamed module @2aec617a'
Exception in Application start method
Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
        at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
        at java.base/java.lang.Thread.run(Thread.java:831)
Caused by: javafx.fxml.LoadException:
file:/C:/Users/user/Desktop/MP3Player.jar!/resources/FXML/homePage.fxml:15

        at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2707)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2685)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3323)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3280)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3249)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3222)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3199)
        at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3192)
        at main.Main.start(Main.java:18)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
        at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:474)
        at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:447)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
        at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:446)
        at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
        at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
        ... 1 more
Caused by: java.lang.IllegalArgumentException: Invalid URL: Invalid URL or resource not found
        at javafx.scene.image.Image.validateUrl(Image.java:1125)
        at javafx.scene.image.Image.<init>(Image.java:618)
        at main.HomePageController.<init>(HomePageController.java:56)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:78)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
        at java.base/java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:128)
        at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:350)
        at java.base/java.lang.Class.newInstance(Class.java:642)
        at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:938)
        at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.java:982)
        at javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:229)
        at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:754)
        at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2808)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2634)
        ... 17 more
Caused by: java.lang.IllegalArgumentException: Invalid URL or resource not found
        at javafx.scene.image.Image.validateUrl(Image.java:1117)
        ... 32 more

drew attention to the line
Caused by: java.lang.IllegalArgumentException: Invalid URL: Invalid URL or resource not found
        at javafx.scene.image.Image.validateUrl(Image.java:1125)
        at javafx.scene.image.Image.<init>(Image.java:618)
        at main.HomePageController.<init>(HomePageController.java:56)

but I didn't understand what "Invalid URL" has to do with it, if everything works fine in the IDE. I am using Intellij IDEA 2021.2 (Community Edition). The SDK is "16 version 16.0.2"

I compiled the JAR file as follows:
File -> Project Structure -> Artifacts -> + -> JAR -> From module with dependences
further indicated Main Class: main.Launcher
and the directory for META- INF/MANIFEST.MF: C:\Users\user\IdeaProjects\MP3Player\src
then in jar I added all .dll files from C:\Program Files\Java\javafx-sdk-16\bin

file MANIFEST.MF:
Manifest-Version: 1.0
Main-Class: main.Launcher


Project structure:
6124f9c16a840178265849.png

In "Edit configurations" I have added the "VM options" parameter:
--module-path
"C:\Program Files\Java\javafx-sdk-16\lib"
--add-modules=javafx.controls,javafx.fxml
--add-modules=javafx.controls,javafx.media


The main class is written in pom.xml (the whole file is attached in the comment):
<mainClass>main.Launcher</mainClass>

I hope I have indicated everything that can help to understand the essence of the problem. I tried to recreate the project, did the build on Gradle, and nowhere did I get a working jar file. Please tell me what I'm doing wrong

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question