Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In a Java 17 modular project, the demo cannot be run and the resource files cannot be loaded correctly. #140

Open
shenbinglife opened this issue Apr 4, 2023 · 1 comment

Comments

@shenbinglife
Copy link

I encountered an error when running the sample code and spent a lot of time learning about Java module-related knowledge. I determined that it is impossible to obtain resource files through ClassLoader and recommended using class.getResourceAsStream instead. Can someone provide an answer? Is this my problem?

Code Version: Java17 + tilesfx 17.1.15

package com.example.javafxdemo._1_TilesFX;

import eu.hansolo.tilesfx.Demo;

class TilesfxDemo {
    public static void main(String[] args) {
        Demo.main(args);
    }
}
Exception in Application start method
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException: inStream parameter is null
	at java.base/java.util.Objects.requireNonNull(Objects.java:233)
	at java.base/java.util.Properties.load(Properties.java:407)
	at eu.hansolo.tilesfx@17.1.15/eu.hansolo.tilesfx.tools.Helper.readProperties(Helper.java:630)
	at eu.hansolo.tilesfx@17.1.15/eu.hansolo.tilesfx.tools.Helper.getHiresCountryPaths(Helper.java:605)
	at eu.hansolo.tilesfx@17.1.15/eu.hansolo.tilesfx.skins.CountryTileSkin.initGraphics(CountryTileSkin.java:90)
	at eu.hansolo.tilesfx@17.1.15/eu.hansolo.tilesfx.skins.TileSkin.<init>(TileSkin.java:130)
	at eu.hansolo.tilesfx@17.1.15/eu.hansolo.tilesfx.skins.CountryTileSkin.<init>(CountryTileSkin.java:72)
	at eu.hansolo.tilesfx@17.1.15/eu.hansolo.tilesfx.Tile.createDefaultSkin(Tile.java:6740)
	at javafx.controls/javafx.scene.control.Control.doProcessCSS(Control.java:897)
	at javafx.controls/javafx.scene.control.Control$1.doProcessCSS(Control.java:89)
	at javafx.controls/com.sun.javafx.scene.control.ControlHelper.processCSSImpl(ControlHelper.java:67)
	at javafx.graphics/com.sun.javafx.scene.NodeHelper.processCSS(NodeHelper.java:146)
	at javafx.graphics/javafx.scene.Node.processCSS(Node.java:9456)
	at javafx.graphics/javafx.scene.Node.processCSS(Node.java:9449)
	at javafx.graphics/javafx.scene.Scene.doCSSPass(Scene.java:572)
	at javafx.graphics/javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2510)
	at javafx.graphics/com.sun.javafx.tk.Toolkit.lambda$runPulse$2(Toolkit.java:421)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at javafx.graphics/com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:420)
	at javafx.graphics/com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:450)
	at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:575)
	at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:555)
	at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulseFromQueue(QuantumToolkit.java:548)
	at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$11(QuantumToolkit.java:353)
	at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
	at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
	at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)
	at java.base/java.lang.Thread.run(Thread.java:833)
@thhart
Copy link

thhart commented Apr 4, 2023

It is a problem with modules in general, loading resources of other modules can be difficult to impossible when not using a class loader of the module where the resource sits in. I don't know if tilesfx is prepared for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants