I\'m getting
java.lang.NullPointerException: Location is required.
when I run my program after assembling using gradle with jav
Try replacing:
javaRuntime = 'C:\\Program Files\\Java\\jdk1.7.0_45'
with:
javaRuntime = 'C:/Program Files/Java/jdk1.7.0_45'
Actually, loading a resource with Gradle might be different from using your IDE resource system.
It is better to use the ClassLoader :
URL myFxmlURL = ClassLoader.getSystemResource("fxml_example.fxml");
FXMLLoader loader = new FXMLLoader(sampleUrl);
Parent root = loader.load(myFxmlURL);
I'm really late to the party...but the accepted didn't work. I (randomly) added 'javafx.fxml' to the list of modules, like this
javafx {
version = "14"
modules = [ 'javafx.controls', 'javafx.fxml']
}
...and it solved the issue.
Your FXML files are probably not packaged into your jar.
Try adding this to your build.gradle file:
sourceSets {
main {
resources {
srcDirs = ["src/main/java"]
includes = ["**/*.fxml"]
}
}
}