r/javahelp • u/juanestragon10 • 1d ago
JPackage is not working
I have this in a build script:
jar ^
--create ^
--file "%BUILD%\input\RocketTracker.jar" ^
--manifest "%BUILD%\MANIFEST.MF" ^
-C "%BUILD%\classes" .
jpackage ^
--type app-image ^
--name RocketTracker ^
--input "%BUILD%\input" ^
--main-jar RocketTracker.jar ^
--main-class app.Main ^
--module-path "%JAVAFX%\lib" ^
--add-modules javafx.controls,javafx.fxml,javafx.graphics,java.net.http ^
--dest "%RELEASE%"
If I run the jar manually adding the modules in the VM it works, but if I run the .exe generated by jpackage it raise an exception:
Graphics Device initialization failed for : d3d, sw
Error initializing QuantumRenderer: no suitable pipeline found
java.lang.RuntimeException: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
at javafx.graphics@21.0.12/com.sun.javafx.tk.quantum.QuantumRenderer.getInstance(Unknown Source)
at javafx.graphics@21.0.12/com.sun.javafx.tk.quantum.QuantumToolkit.init(Unknown Source)
at javafx.graphics@21.0.12/com.sun.javafx.tk.Toolkit.getToolkit(Unknown Source)
at javafx.graphics@21.0.12/com.sun.javafx.application.PlatformImpl.startup(Unknown Source)
at javafx.graphics@21.0.12/com.sun.javafx.application.PlatformImpl.startup(Unknown Source)
at javafx.graphics@21.0.12/com.sun.javafx.application.LauncherImpl.startToolkit(Unknown Source)
at javafx.graphics@21.0.12/com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown Source)
at javafx.graphics@21.0.12/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
at javafx.graphics@21.0.12/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(Unknown Source)
at javafx.graphics@21.0.12/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(Unknown Source)
... 1 more
Exception in thread "main" java.lang.RuntimeException: No toolkit found
at javafx.graphics@21.0.12/com.sun.javafx.tk.Toolkit.getToolkit(Unknown Source)
at javafx.graphics@21.0.12/com.sun.javafx.application.PlatformImpl.startup(Unknown Source)
at javafx.graphics@21.0.12/com.sun.javafx.application.PlatformImpl.startup(Unknown Source)
at javafx.graphics@21.0.12/com.sun.javafx.application.LauncherImpl.startToolkit(Unknown Source)
at javafx.graphics@21.0.12/com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown Source)
at javafx.graphics@21.0.12/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Failed to launch JVM
Any idea how to fix it? the same code in bash works just fine and the path are checked already
1
u/idontlikegudeg 1d ago
Try using Liberica Full JDK without the —module-path and —add-modules JavaFX…
1
u/juanestragon10 1d ago
What difference would it make? Isnt it just the same but instead of adding them manually they are added by Liberica?
1
u/idontlikegudeg 1d ago
JavaFX uses platform dependent native libraries. The errors you get seem to indicate that the platform independent JacaFX stubs got linked. Liberica does not contain these, so I think it might work.
2
u/milchshakee 1d ago edited 1d ago
Are you intending to use --type app-image for an exe? There is a --type exe, but maybe that doesn't matter here, maybe there is a fallback. Edit: Maybe that is the correct type, I don't use jpackage from the command line
If you use the JavaFX SDK, that one tries to locate the native libraries to load and fails here.
Usually for tasks like jlink and jpackage, the JavaFX .jmods are the right ones to use intead of jars as the native libraries get copied into the correct bin directory of the runtime image.
1
u/juanestragon10 1d ago
Yes, when I change type with exe it throws an error but it still generates an .exe with app-image, i will test with the jmods, it works in linux with the sdk but will try anyways, thx
1
2
u/NaveenB2004 1d ago
Seems like something to do with the javafx.graphics module. Can you give more info about the matter? You said that it's working with Bash, which means on Linux? Then you cannot use the same JavaFX SDK to build it for Windows and vise versa.
1
u/juanestragon10 1d ago
Yes, it works in linux just fine, and yes, I downloaded the windows version, you can check more in this repo if you please: github.com/juanestragon/RocketTracker
2
u/NaveenB2004 1d ago
The 'javafx.graphics' module uses platform-dependent native code under the abstraction layer provided for Java applications. So the module will fail at runtime because it cannot find the platform-dependent graphics pipelines, in your case.
The fix for JPackage: When using the tool, make sure you replace the JFX modules to match the host (ex: on Windows, use JFX SDK released for Widnows; on Linux, use JFX SDK released for Linux. etc.) Since the installer cannot be built without the native platform, this is the only feasible method I see.
Alternative approach: Use JLink. Then you can cross-compile for all the platforms without hopping hosts (will relate to JFX in next section). The drawback is that you will not get a direct executable, but a script file to run the application (no exe but a bat/sh). But it will not solve the host-dependent JFX problem. But...
Use Build System: Seems like you don't use a build system and are purely relying on handwritten scripts. If you switch to a project management tool like Maven, you may be able to mix the JLink and JFX dependencies to make it more convenient for the releases. If you are interested, check this: https://github.com/NaveenB2004/SelfContained-JFX
•
u/AutoModerator 1d ago
Please ensure that:
You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.
Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar
If any of the above points is not met, your post can and will be removed without further warning.
Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.
Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.
Code blocks look like this:
You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.
If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.
To potential helpers
Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.