JavaFX error
In my project coded with JavaFX, I get a JavaFX runtime error, and after installing with the .msi the application doesn’t run, but when I run it as a Gradle project from IntelliJ, it works.
106 Replies
⌛
This post has been reserved for your question.
Hey @feca! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
What exact error?
Can you create it with
--win-console
?
How are you using jpackage
?I was trying to do it with Cursor AI in order to set it up, I have a Gradle file.
Error: JavaFX runtime components are missing, and are required to run this application
Are you getting that with jpackage or without it?
both
but when i run with gradle, it works
How are you running it without jpackage that you get that error? Are you using a fat JAR? If so, that's the issue
I’ve added --win-console to my jpackage Gradle task. Do you want me to send you my Gradle file to check?
please
No, I’m not running a fat JAR. I just run it with ./gradlew run from the terminal, and it works fine there. The issue only happens after packaging with jpackage.
Can you please show the build script/how you are running jpackage?
Do you have a module-info.java?
cursor removed it
ill add now
oh you are doing it manually with the JavaFX SDK...
yes
yeah that is far from ideal
JavaFX wants to run with a module-info.java
Yesterday I tried every possible way, I even downloaded the JavaFX SDK, but the same error kept happening.
now i added module-info.java
You should ideally get rid of the
open
keyword before module
(and replace it with exports
/opens
) once the application works but it should be fine/easier for now
Then you should also not need to use --add-opens
My project is classpath-based, so Cursor removed the module-info.
JavaFX doesn't support using the classpath for it.
now i added the module-info
and here's my module info
but when i compile it
ok yeah that should probably be fine for the most part
compile error
and for jpackage, you might want to do it like https://openjfx.io/openjfx-docs/#modular but we'll see about it once you get the module-info.java to work
Getting Started with JavaFX
Getting started with JavaFX for Java desktop application development
Is jnativehook on the modulepath?
Also jnativehook should support modules: https://github.com/kwhat/jnativehook/blob/2.2/src/main/java/module-info.java
GitHub
jnativehook/src/main/java/module-info.java at 2.2 · kwhat/jnativehook
Global keyboard and mouse listeners for Java. Contribute to kwhat/jnativehook development by creating an account on GitHub.
now i see nativehook is on the classpath, not the module-path
it should be on the modulepath
all dependencies should be in the modulepath
im trying
btw since you said you weren't using a fat JAR before, you configured the project to create one:
What Gradle version are you using?
Can you update jnativehook to version 2.2.2?
I think 2.1.0 didn't support modules
i use gradle 8.5
so you need to use jnativehook 2.2.2
allright i will use jnh 2.2.2 version
Here's my new build.gradle
And module-info
I switched 2.2.2 version for jnativehook
When i runs with batch file, it works. But i want to its work with directly
The batch file content:
Wha happens when you run the project now?
Also why are you using
jdk.unsupported
?
And also java.desktop
, java.management
, java.naming
, java.scripting
, crypto/security modules and many others?I was developing this project with JDK 24 at the beginning, but then a friend told me that it’s not an LTS and suggested I switch to JDK 21 or 17, so I moved to 21. I actually had those parts of the project made by Cursor AI. Now I’m trying to create an installer with JPackage, but after I open and install the .msi file, when I try to launch the .lnk shortcut on the desktop, nothing shows up.
but when i try to run with ./gradlew run, it works
i dont understand
actually had those parts of the project made by Cursor AIThis is not an excuse for writing bad code in any way. You are responsible for the code you are writing. You need to understand everything you are writing.
an installer with JPackage, but after I open and install the .msi file, when I try to launch the .lnk shortcut on the desktop, nothing shows upDoes it work with the module-info.java without jpackage?
Yes, I know, I’m still a new developer and I’m working on understanding the code.
When I run the project from the terminal with Gradle, it works fine. However, when I try to run it directly using Shift + F9, I get the following error: 'Error: JavaFX runtime components are missing, and are required to run this application.'
By the way, do you have any tips on how I can get better at Java? You seem to know it really well, and I’d love to improve and one day reach a senior level too. Even a bug like this has been keeping me stuck for days.
I see. Can you try reimporting the project into your IDE?
My main tip is not relying on AI tools
also modularity issues can be complicated and being stuck at these for a long time is normal ;)
i did it 3 times
i see thank you :D
Is JavaFX on your modulepath in your IDE?

Can you show the full text shown in the console?
I think IntelliJ should show the full command at the start
this error shown me when i start with shift + f9
oh right IntelliJ just runs Gradle
yes i can only run this project with gradle
Does the same issue occur when running it from the command line with Gradle?
PS C:\Users\rampa\OneDrive\Desktop\Projects\ClickMaster Pro> ./gradlew run
Configuration on demand is an incubating feature.
<---<<<<<<<<<<<
Task :runnClickMaster Pro v2.0.1 starting... Launching JavaFX application... Initializing engines... ClickerEngine initialized HotkeyEngine initialized Setting up UI... Creating MainView... . . . so it runs with gradle
I think it's related to that
Can you try to remove the following temporarily/for testing?
Where do you have your module-info.java?
in the src > main > java > module-info.java
i did it

Does
gradlew run
still work?yes it works
Does it also work if you remove the entire
jvmArgs = [ ... ]
block?lets try
it works
Can you show the run configuration in IntelliJ?

Can you remove the JVM args from it?
like this?

yes
Error: JavaFX runtime components are missing, and are required to run this application
20:02:23: Executing ':org.example.ClickMasterApp.main()'…
Configuration on demand is an incubating feature.
Task :compileJava UP-TO-DATE Task :processResources UP-TO-DATE Task :classes UP-TO-DATE
Task :org.example.ClickMasterApp.main() FAILED3 actionable tasks: 1 executed, 2 up-to-date Error: JavaFX runtime components are missing, and are required to run this application FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':org.example.ClickMasterApp.main()'.
Process 'command 'C:\Program Files\Java\jdk-21\bin\java.exe'' finished with non-zero exit value 1* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. Get more help at https://help.gradle.org.BUİLD FAILED in 355ms 20:02:24: Execution finished ':org.example.ClickMasterApp.main()'.
Can you remove the run configuration and restart it?
i start with current file

and again...
Can you run
gradlew :org.example.ClickMasterApp.main()
?
Does that do anything?oh I just saw that - you would also need to remove that

then it being like this

What options are there in that menu?
sdk
and the main class
I meant in that menu

oh

if i select clickmaster_pro.main

yeah it should be that one
but the
-cp
looks wrong
that is with the main one?

use the one with
.main
Using this
Is there a
Use classpath of module
setting anywhere?here's the all menu

i think there isnt or i couldnt see
and it works with none of the options?
I tried every setting, but nothing worked.
Can you remove the run configuration and just start it again?
oh i find a way

when i do this it works
For jpackage, I'd do it similar to https://openjfx.io/openjfx-docs/#modular
Getting Started with JavaFX
Getting started with JavaFX for Java desktop application development
so instead of your custom jpackage command, you would do it somewhat similar to
in your build.gradle
what if
yeah something like that
then
Why that?
is that it tells JLink to create a custom merged module by combining your own module with the specified modules.
However, in many cases this is unnecessary or can complicate things, because you already have a modular project (module-info.java). Using addModules is simpler and safer, as it just includes the required JavaFX modules in the runtime image without creating a merged module.
but why are you using it here?
Also I asked you and not your LLM
because I didn’t want the user to get an error after installing the setup via .msi
and i trying some ways
which error are you getting without it?
that
mergedModule
setup is definitely not something JavaFX supportshonestly, every time I ran it, I got a JavaFX runtime error. In the file that came from the setup, when I tried to run the desktop file, nothing appeared on the screen, meaning it didn’t open
then, what if:
is it work?
jlink build is successful
we can try
Did that generate an msi?
I think you need
./gradlew jpackage
thoughmsi file created but still isn't working. but ill try some way now.
What happens when installing the msi and then running the installed app from the console?
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.