1

I am getting a NullPointerException regarding the location of my FXML. However, this only started to happen after I upgraded my JavaFX version (I need 13 to meet project requirements).

My main class:

public class Main extends Application {

@Override
public void start(Stage primaryStage) throws IOException {

    String path = "/fxml/loginScene.fxml";

    Parent root = FXMLLoader.load(getClass().getResource(path));
    primaryStage.initStyle(StageStyle.UNDECORATED);

    Scene scene = new Scene(root);
    primaryStage.setScene(scene);
    primaryStage.getIcons().add(new Image(getClass().getResourceAsStream("/imgs/icon.png")));
    primaryStage.show();
}

public static void main(String[] args) {
    launch(args);
}
}

module-info:

module main {
requires javafx.controls;
requires javafx.fxml;
requires jfoenix;
requires vlcj;

opens me.fullcam.mosaicov2 to javafx.fxml;
exports me.fullcam.mosaicov2;
}

My directories:

enter image description here

The exception:

    Exception in Application start method
java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.RuntimeException: Exception in Application start method
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
    at java.base/java.lang.Thread.run(Thread.java:835)
Caused by: java.lang.NullPointerException: Location is required.
    at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3230)
    at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3194)
    at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3163)
    at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3136)
    at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3113)
    at javafx.fxml/javafx.fxml.FXMLLoader.load(FXMLLoader.java:3106)
    at main/me.fullcam.mosaicov2.Main.start(Main.java:20)

My build.gradle:

    plugins {
    id 'application'
    id 'org.openjfx.javafxplugin' version '0.0.8'
    id 'org.beryx.jlink' version '2.12.0'
}

repositories {
    mavenCentral()
}

dependencies {
    compile group: 'uk.co.caprica', name: 'vlcj', version: '4.2.0'
    compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.0.1'
    compile group: 'com.google.http-client', name: 'google-http-client', version: '1.23.0'
    compile group: 'com.jfoenix', name: 'jfoenix', version: '8.0.9'
    compile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.28'
}

javafx {
    version = "13"
    modules = [ 'javafx.controls', 'javafx.fxml' ]
}

mainClassName = "$moduleName/me.fullcam.mosaicov2.Main"

jlink {
    options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
    launcher {
        name = 'mosaico-desktop'
    }
}

I think that everything is in order, but resources aren't being added to the classpath. I have not found anything like that. I'm using IntelliJ.

I've tryied ./gradlew clean --info run, but that's my stacktrace:

> Task :run FAILED
Task ':run' is not up-to-date because:
  Task has not declared any outputs despite executing actions.
Starting process 'command '/usr/lib/jvm/java-12-oracle/bin/java''. Working directory: /home/leonardo/Modelos/IdeaProjects/FullCam/Desktop/mosaico-desktop-v2 Command: /usr/lib/jvm/java-12-oracle/bin/java --add-modules javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media --module-path /home/leonardo/Modelos/IdeaProjects/FullCam/Desktop/mosaico-desktop-v2/build/classes/java/main:/home/leonardo/Modelos/IdeaProjects/FullCam/Desktop/mosaico-desktop-v2/build/resources/main:/root/.gradle/caches/modules-2/files-2.1/uk.co.caprica/vlcj/4.2.0/727b20426956174d64c6817367f45080ad95a4d0/vlcj-4.2.0.jar:/root/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-databind/2.0.1/1d160beb3f8924d5b98d03d94a149021146f71cc/jackson-databind-2.0.1.jar:/root/.gradle/caches/modules-2/files-2.1/com.google.http-client/google-http-client/1.23.0/8e86c84ff3c98eca6423e97780325b299133d858/google-http-client-1.23.0.jar:/root/.gradle/caches/modules-2/files-2.1/com.jfoenix/jfoenix/8.0.9/71da4db8303be22f6366df8933dd93519398c8f8/jfoenix-8.0.9.jar:/root/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-simple/1.7.28/cf5f2cf3c31e0e41b68d932d756398a1238d4456/slf4j-simple-1.7.28.jar:/root/.gradle/caches/modules-2/files-2.1/org.openjfx/javafx-fxml/13/2c1016c361ce5797927e9e14847fbca9bebf3bd5/javafx-fxml-13-linux.jar:/root/.gradle/caches/modules-2/files-2.1/org.openjfx/javafx-controls/13/bcedf8eb6e11c2a7908b3126004d41274f6334f3/javafx-controls-13-linux.jar:/root/.gradle/caches/modules-2/files-2.1/org.openjfx/javafx-controls/13/6cd7169d2a729846c35fba9dc65af23a10ca253b/javafx-controls-13.jar:/root/.gradle/caches/modules-2/files-2.1/org.openjfx/javafx-media/13/d3626ef7290012a1e55a32532977ed78edc02548/javafx-media-13-linux.jar:/root/.gradle/caches/modules-2/files-2.1/org.openjfx/javafx-graphics/13/d853d12684f60037dfeea1a47e61396e0febfdfd/javafx-graphics-13-linux.jar:/root/.gradle/caches/modules-2/files-2.1/org.openjfx/javafx-graphics/13/a9407212df2b75d557a509ec14a9e8e282494b4e/javafx-graphics-13.jar:/root/.gradle/caches/modules-2/files-2.1/org.openjfx/javafx-base/13/828b1e1a35104bb0f26a347c2716d553ca4cf4d2/javafx-base-13-linux.jar:/root/.gradle/caches/modules-2/files-2.1/org.openjfx/javafx-base/13/43c52e1d11b38514e9d2421ad98ca6a35de12b0/javafx-base-13.jar:/root/.gradle/caches/modules-2/files-2.1/uk.co.caprica/vlcj-natives/4.1.0/d45eb15ac25a1c085a365166d430435bd990409d/vlcj-natives-4.1.0.jar:/root/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-annotations/2.0.1/36e5996abe8655a6471b82af5ac1cd6786aecf85/jackson-annotations-2.0.1.jar:/root/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-core/2.0.1/481d14ec21e034ed45217c4854dbbf15940ce108/jackson-core-2.0.1.jar:/root/.gradle/caches/modules-2/files-2.1/com.google.code.findbugs/jsr305/1.3.9/40719ea6961c0cb6afaeb6a921eaa1f6afd4cfdf/jsr305-1.3.9.jar:/root/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpclient/4.0.1/1d7d28fa738bdbfe4fbd895d9486308999bdf440/httpclient-4.0.1.jar:/root/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-api/1.7.28/2cd9b264f76e3d087ee21bfc99305928e1bdb443/slf4j-api-1.7.28.jar:/root/.gradle/caches/modules-2/files-2.1/net.java.dev.jna/jna-platform/5.2.0/5520c6f3382801576547dd20854225ae2899b649/jna-platform-5.2.0.jar:/root/.gradle/caches/modules-2/files-2.1/net.java.dev.jna/jna/5.2.0/ed8b772eb077a9cb50e44e90899c66a9a6c00e67/jna-5.2.0.jar:/root/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpcore/4.0.1/e813b8722c387b22e1adccf7914729db09bcb4a9/httpcore-4.0.1.jar:/root/.gradle/caches/modules-2/files-2.1/commons-logging/commons-logging/1.1.1/5043bfebc3db072ed80fbd362e7caf00e885d8ae/commons-logging-1.1.1.jar:/root/.gradle/caches/modules-2/files-2.1/commons-codec/commons-codec/1.3/fd32786786e2adb664d5ecc965da47629dca14ba/commons-codec-1.3.jar --patch-module main=/home/leonardo/Modelos/IdeaProjects/FullCam/Desktop/mosaico-desktop-v2/build/resources/main --module main/me.fullcam.mosaicov2.Main -Dfile.encoding=UTF-8 -Duser.country=BR -Duser.language=pt -Duser.variant main/me.fullcam.mosaicov2.Main
Successfully started process 'command '/usr/lib/jvm/java-12-oracle/bin/java''
/home/leonardo/Modelos/IdeaProjects/FullCam/Desktop/mosaico-desktop-v2/.
Exception in Application start method
java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:567)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:567)
        at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.RuntimeException: Exception in Application start method
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
        at java.base/java.lang.Thread.run(Thread.java:835)
Caused by: java.lang.NullPointerException: Location is required.
        at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3230)
        at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3194)
        at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3163)
        at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3136)
        at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3113)
        at javafx.fxml/javafx.fxml.FXMLLoader.load(FXMLLoader.java:3106)
        at main/me.fullcam.mosaicov2.Main.start(Main.java:22)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:389)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
        at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
        at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
        at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277)
        ... 1 more
Exception running application me.fullcam.mosaicov2.Main
:run (Thread[Task worker for ':',5,main]) completed. Took 0.574 secs.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':run'.
> Process 'command '/usr/lib/jvm/java-12-oracle/bin/java'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
5 actionable tasks: 5 executed

FearX
  • 317
  • 3
  • 16
  • If you run from a terminal `./gradlew run`, or if you run from the Gradle window in IntelliJ, `Tasks-> application -> run`, it will work again. The problem is only when you try to run as a Java application from IntelliJ, isn't it? – José Pereda Oct 03 '19 at 20:01
  • Hello, José. No, even with gradle I have this same exception – FearX Oct 03 '19 at 20:10
  • Try `./gradlew clean --info run`. Can you verify what do you see in the `build` folder? You should get `build/classes/java/main/me...` and also `build/resources/main/fxml/...`. If it doesn't work, edit your question and post the full exception stack trace and the command line. – José Pereda Oct 03 '19 at 20:25
  • @JoséPereda, I've looked into my build and out folders, and seems to be everything ok. I've done System.out.println(new File(".").getAbsolutePath()); to see where I'm, and it seems to be at /home/leonardo/Modelos/IdeaProjects/FullCam/Desktop/mosaico-desktop-v2/. I'll edit the post – FearX Oct 03 '19 at 20:33
  • The absolute path is not relevant. Run `./gradlew clean --info run` from the terminal, and then edit your question and post the full exception stack trace and the java command line – José Pereda Oct 03 '19 at 20:36
  • post updated with infos – FearX Oct 03 '19 at 20:40
  • Everything looks good. A possible explanation is that there is a mismatch between the fxml name and getResource(fxml).... Double check that. Also make sure there are no errors in your project (your pic shows some). – José Pereda Oct 03 '19 at 21:03
  • There's no error in the name. Could it be the version of JavaFX? I've upgraded it to 13, since then it is giving this exception – FearX Oct 04 '19 at 11:04
  • Not really, 11 or 12 work for you? Easy to test out. – José Pereda Oct 04 '19 at 11:05
  • It won't work, cause I need to work with PixelBuffer, and it only comes in FX13 :/ – FearX Oct 04 '19 at 11:17
  • I see. I have a test case with JavaFX 13, IntelliJ, Gradle, modular, same `fxml` folder for resources and it works perfectly fine. Can you share your project? Else, can you make a MVCE? – José Pereda Oct 04 '19 at 11:21
  • I don't know if it be a complete MVCE, but check it out [here](https://github.com/fearchannel/javafx13-issue). I made a small replica of the project (because it is confidential), hope you can understand. – FearX Oct 04 '19 at 11:55
  • Sorry, but it is not a _working_ MVCE: doesn't run (at least until I can get your same exception). Missing controller, missing css file, it doesn't work on Java 11+ (JFoenix should be 9.0.9), missing --add-exports, ... Can you fix that? – José Pereda Oct 04 '19 at 12:02
  • With your tips I think that I can. But didn't understand how to make a _working_ sample, after all i'm with this issue – FearX Oct 04 '19 at 12:17
  • @JoséPereda can u see it now? – FearX Oct 04 '19 at 12:31
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/200397/discussion-between-fearx-and-jose-pereda). – FearX Oct 04 '19 at 12:31

2 Answers2

2

Based on the posted MVCE project, these are a few modifications that are required to make the project work:

build.gradle

Based on this:

plugins {
    id 'application'
    id 'org.openjfx.javafxplugin' version '0.0.8'
    id 'org.beryx.jlink' version '2.12.0'
}

group 'me.project.desktop'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    compile group: 'uk.co.caprica', name: 'vlcj', version: '4.2.0'
    compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.0.1'
    compile group: 'com.google.http-client', name: 'google-http-client', version: '1.23.0'
    compile group: 'com.jfoenix', name: 'jfoenix', version: '8.0.9'
    compile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.28'
}

javafx {
    version = "13"
    modules = [ 'javafx.controls', 'javafx.fxml', 'javafx.base', 'javafx.graphics', 'javafx.media' ]
}

mainClassName = "me.project.mosaic.Main"

jlink {
    options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
    launcher {
        name = 'mosaico-desktop'
    }
}

The required changes are:

  • Set Java level to 11

  • Update dependencies

JFoenix is set to 8.0.9, that is intended for Java 1.8. If you run with Java 11+, you will get an exception:

Caused by: java.lang.ClassNotFoundException: com.sun.javafx.css.converters.PaintConverter
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)

Since JDK 9, CSS converters are public API, so you need JFoenix for 9, like 9.0.9.

See for reference this post.

  • Use JDK 11, not 12 or 13

JFoenix's JFXTextField control has an standing issue with the use of reflection to access private API.

java.lang.IllegalAccessException: class com.jfoenix.skins.JFXTextFieldSkin cannot access a member of class javafx.scene.control.skin.TextFieldSkin (in module javafx.controls) with modifiers "private"
        at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:376)
...
java.lang.IllegalAccessException: class com.jfoenix.skins.JFXTextFieldSkin cannot access a member of class javafx.scene.control.skin.TextFieldSkin (in module javafx.controls) with modifiers "private"
        at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:376)
        at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:639)
...  

and that causes a null pointer exception:

Caused by: java.lang.NullPointerException
        at com.jfoenix.skins.JFXTextFieldSkin.updateTextPos(JFXTextFieldSkin.java:109)

Running with Java 11, it works fine.

For reference, see this post.

  • Add exports

JFoenix uses private API, so it requires a bunch of exports, that have to be added to the VM arguments, like:

run {

    jvmArgs = [

        "--add-exports=javafx.controls/com.sun.javafx.scene.control.behavior=ALL-UNNAMED",

        "--add-exports=javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED",

        "--add-exports=javafx.base/com.sun.javafx.binding=ALL-UNNAMED",
        "--add-exports=javafx.graphics/com.sun.javafx.stage=ALL-UNNAMED",
        "--add-exports=javafx.controls/com.sun.javafx.scene.control.behavior=ALL-UNNAMED"
    ]

}

For reference, see this.

This will be the resulting build.gradle file:

plugins {
    id 'application'
    id 'org.openjfx.javafxplugin' version '0.0.8'
    id 'org.beryx.jlink' version '2.12.0'
}

group 'me.project.desktop'
version '1.0-SNAPSHOT'

sourceCompatibility = 11

repositories {
    mavenCentral()
}

dependencies {
    compile group: 'uk.co.caprica', name: 'vlcj', version: '4.2.0'
    compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.0.1'
    compile group: 'com.google.http-client', name: 'google-http-client', version: '1.23.0'
    compile group: 'com.jfoenix', name: 'jfoenix', version: '9.0.9'
    compile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.28'
}

javafx {
    version = "13"
    modules = [ 'javafx.controls', 'javafx.fxml', 'javafx.base', 'javafx.graphics', 'javafx.media' ]
}

run {
    jvmArgs = ["--add-exports=javafx.controls/com.sun.javafx.scene.control.behavior=ALL-UNNAMED",
        "--add-exports=javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED",
        "--add-exports=javafx.base/com.sun.javafx.binding=ALL-UNNAMED",
        "--add-exports=javafx.graphics/com.sun.javafx.stage=ALL-UNNAMED",
        "--add-exports=javafx.controls/com.sun.javafx.scene.control.behavior=ALL-UNNAMED"
    ]
}

mainClassName = "me.project.mosaic.Main"

jlink {
    options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
    launcher {
        name = 'mosaico-desktop'
    }
}

Running (with JDK 11):

./gradlew clean run

will work.

Modular project

In order to run jlink, you need to create a modular descriptor, like:

module mosaic.viewer {
    requires javafx.controls;
    requires javafx.fxml;
    requires com.jfoenix;
    requires vlcj;
    requires jackson.annotations;
    requires jackson.databind;
    requires jackson.core;
    requires google.http.client;
    requires org.slf4j;
    requires jsr305;

    opens me.project.mosaic.login to javafx.fxml;
    exports me.project.mosaic;
}
  • Open package

Since FXML uses reflection, you have to open to the javafx.fxml module the package(s) with the controller(s). In this case: opens me.project.mosaic.login to javafx.fxml;.

  • Add exports

Since you have a named module now, the --add-exports are now set to com.jfoenix instead of ALL-UNNAMED.

Running (with JDK 11):

./gradlew clean jlink

will create a custom image, and you will be able to run the generated image from the launcher script:

build/image/bin/mosaic-desktop

IDE

If you run the project from your IDE (IntelliJ) and not from a terminal, make sure you use the Gradle window for IntelliJ, that will show you the project and available tasks.

It is important to set in Project Structure -> Project the project SDK and language level to 11.

Also, the Gradle window has a settings button, click on it, and make sure that the Gradle JVM is also set to JDK 11.

You can run from this window:

  • Tasks -> application -> run

  • Tasks -> build -> jlink

Finally, you can also create Run configurations, but based on Gradle, with the above tasks.

José Pereda
  • 44,311
  • 7
  • 104
  • 132
  • Hello. When I generate a Jar using jlink task, this error is popped out when I try to run the jar: no main manifest attribute, in mosaico-desktop-1.0-SNAPSHOT.jar – FearX Oct 07 '19 at 11:24
  • Jlink doesn't generate jars, but custom JREs for a given platform. You can zip it and distribute it, unzip it and run a script. If you have a modular app, that is how it should be done. Of course you can still do a fat jar (it will work only on that platform), following the [instructions](https://openjfx.io/openjfx-docs/#modular) for non-modular projects with gradle. – José Pereda Oct 07 '19 at 11:32
  • I think that I have a modular project, but don't need to. It's just one module, after all, and this is giving me some serious headaches. So, if I need to generate a single jar that will work in all platforms, I should run a script? – FearX Oct 07 '19 at 11:37
  • Again, just follow the [instructions](https://openjfx.io/openjfx-docs/#modular) for non-modular projects with gradle, and modify the `jar` task. You can make it multi-platform. – José Pereda Oct 07 '19 at 11:40
-1

Yes, the Location is required exception means that the resource passed into the FXMLLoader.load(...) method was null—i.e. not on your classpath.

It could be that you have supplied the wrong path or that you're using the wrong classloader or that you have misconfigured your classpath when you run the application. Perhaps that file is in your source folder but not being copied into the classes folder?

It's hard to debug from here. You need to work out where that .fxml file is located and make sure that it is on the classpath.

Alternatively, you could load it from a file. E.g.

URL url = new File("C:/fxml/loginScene.fxml").toURI().toURL();
Parent root = FXMLLoader.load(url);
ᴇʟᴇvᴀтᴇ
  • 12,285
  • 4
  • 43
  • 66