@devpy14

Ошибка Unsupported JavaFX configuration: classes were loaded from 'unnamed module @121464c3' при запуске jar-файла?

При запуске jar-файла через cmd выдаёт следующую ошибку:
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

Обратил внимание на строчку
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)

но не понял, при чём здесь "Invalid URL", если в IDE всё работает нормально. Пользуюсь Intellij IDEA 2021.2 (Community Edition). SDK стоит "16 version 16.0.2"

JAR-файл я собирал следующим образом:
File -> Project Structure -> Artifacts -> + -> JAR -> From module with dependences
далее указал Main Class: main.Launcher
и директорию для META-INF/MANIFEST.MF: C:\Users\user\IdeaProjects\MP3Player\src
затем в jar я добавил все .dll файлы из директории C:\Program Files\Java\javafx-sdk-16\bin

файл MANIFEST.MF:
Manifest-Version: 1.0
Main-Class: main.Launcher


Структура проекта:
6124f9c16a840178265849.png

В "Edit configurations" у меня добавлен параметр "VM options":
--module-path
"C:\Program Files\Java\javafx-sdk-16\lib"
--add-modules=javafx.controls,javafx.fxml
--add-modules=javafx.controls,javafx.media


В pom.xml main-класс прописан(весь файл прикреплен в комментарии):
<mainClass>main.Launcher</mainClass>

Надеюсь, указал всё, что может помочь понять суть проблемы. Пытался пересоздавать проект, делал сборку на Gradle, и нигде не получился работающий jar-файл. Умоляю, скажите, что я делаю не так)
  • Вопрос задан
  • 217 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы