0

When running a 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

I paid 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 the "Invalid URL" has to do with it, if everything works fine in the IDE. I am using Intellij IDEA 2021.2 (Community Edition). SDK is "16 version 16.0.2"

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

MANIFEST.MF file:

Manifest-Version: 1.0
Main-Class: main.Launcher

Project structure:

MP3Player
├──.idea
├──out
├──src(marked as Source)
│  ├──main
│  │  ├──HomePageController.java
│  │  ├──Launcher.java
│  │  ├──Main.java
│  │
│  ├──recources
│     ├──FXML
│     ├──images
│     ├──media
│     ├──app.css
│     ├──nightApp.css
│     ├──sidebar.css
│
├──target
├──.gitignore
├──MP3Player.iml
├──pom.xml
├──README.md

In "Edit configurations" I added the parameter "VM parameters":

--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:

<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, but jar-file does not work. PLEASE tell me what I'm doing wrong)

  • Check the JAR file; are the resources present? Also, you mention that `src` is marked as a source directory. But it seems like `src/main` should be marked as the source directory instead and `src/resources` should be marked as a resources directory. Does making that change fix the `IllegalArgumentException` problem? – Slaw Aug 25 '21 at 03:28
  • As for the warning (not error) you mention in your question's title, check out [this answer](https://stackoverflow.com/questions/67854139/javafx-warning-unsupported-javafx-configuration-classes-were-loaded-from-unna/67854230#67854230). It should at least explain why you see the warning, if not help you make it go away. – Slaw Aug 25 '21 at 03:31

0 Answers0