#JavaFX error
154 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @marsh loom! Please use
/closeor theClose Postbutton 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.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
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?
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?
oh you are doing it manually with the JavaFX SDK...
yes
Yesterday I tried every possible way, I even downloaded the JavaFX SDK, but the same error kept happening.
now i added module-info.java
open module your.moduleName.here {
requires javafx.controls;
requires javafx.fxml;
requires javafx.graphics;
requires javafx.base;
}
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
requires javafx.controls;
requires javafx.fxml;
requires javafx.graphics;
requires javafx.base;
// JNativeHook - automatic module
requires static jnativehook;
// Logging
requires static ch.qos.logback.classic;
requires static ch.qos.logback.core;
// JSON processing
requires static com.fasterxml.jackson.databind;
requires static com.fasterxml.jackson.core;
// Java modules
requires java.desktop;
requires java.logging;
// Exports
exports org.example;
exports org.example.core;
exports org.example.ui;
exports org.example.ui.components;
exports org.example.utils;
exports org.example.security;
exports org.example.animation;
// Opens for reflection
opens org.example to javafx.graphics;
opens org.example.ui to javafx.fxml;
opens org.example.ui.components to javafx.fxml;
}
but when i compile it
ok yeah that should probably be fine for the most part
Configuration on demand is an incubating feature.
<-<<
> Task :compileJava FAILED
C:\Users\rampa\OneDrive\Desktop\Projects\ClickMaster\src\main\java\module-info.java:8: error: module not found: jnativehook
requires static jnativehook;
^
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
> Run with --info option to get more log output.
> Run with --scan to get full insights.
BU─░LD FAILED in 1s
2 actionable tasks: 2 executed
PS C:\Users\rampa\OneDrive\Desktop\Projects\ClickMaster>
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 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
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
im trying
btw since you said you weren't using a fat JAR before, you configured the project to create one:
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
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
* ClickMaster Pro - Modüler JavaFX Uygulaması
*
* Bu modül, ClickMaster Pro uygulamasının ana modülüdür.
* JavaFX, JNativeHook, Jackson ve Logback bağımlılıklarını içerir.
*
* Modül Açıklaması:
* - JavaFX 21.0.2 modülleri (controls, fxml, graphics, base)
* - JNativeHook 2.2.2 global hotkey desteği
* - Jackson JSON işleme (core, databind)
* - Logback logging framework (classic, core, slf4j-api)
* - Java platform modülleri (desktop, logging, management, vb.)
*/
module org.example {
// JavaFX modülleri
requires javafx.controls;
requires javafx.fxml;
requires javafx.graphics;
requires javafx.base;
// JNativeHook - Global hotkey desteği
requires com.github.kwhat.jnativehook;
// Jackson JSON işleme
requires com.fasterxml.jackson.core;
requires com.fasterxml.jackson.databind;
// Logback logging framework
requires org.slf4j;
requires ch.qos.logback.classic;
requires ch.qos.logback.core;
// Java platform modülleri
requires java.desktop;
requires java.logging;
requires java.management;
requires java.naming;
requires java.security.jgss;
requires java.instrument;
requires java.scripting;
requires java.sql;
requires java.xml;
// JDK modülleri
requires jdk.unsupported;
requires jdk.crypto.ec;
requires jdk.security.auth;
requires jdk.net;
// Modül açma izinleri - JavaFX FXML için
opens org.example to javafx.fxml;
opens org.example.ui to javafx.fxml;
opens org.example.ui.components to javafx.fxml, javafx.graphics;
// Modül dışa aktarma
exports org.example;
exports org.example.ui;
exports org.example.ui.components;
}
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:
@echo off
REM ClickMaster Pro Launcher
REM Gradle run kullanarak çalıştırır
cd /d "C:\Users\rampa\OneDrive\Desktop\Projects\ClickMaster Pro"
REM Gradle run ile çalıştır
gradlew.bat run
pause```
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 AI
This 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 up
Does 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
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() FAILED
3 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 449ms
19:54:18: Execution finished ':org.example.ClickMasterApp.main()'.```
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 :runn
ClickMaster 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
run {
// Modül path ayarları
jvmArgs = [
'--add-modules', 'javafx.controls,javafx.fxml,javafx.graphics,javafx.base',
'--add-opens', 'java.base/java.lang=ALL-UNNAMED',
'--add-opens', 'java.base/java.util=ALL-UNNAMED',
'--add-opens', 'java.desktop/java.awt=ALL-UNNAMED',
'--add-opens', 'java.desktop/java.awt.event=ALL-UNNAMED',
'--module-path', configurations.runtimeClasspath.asPath
]
// IntelliJ IDEA için ek ayarlar
standardInput = System.in
standardOutput = System.out
errorOutput = System.err
}
Can you try to remove the following temporarily/for testing?
'--add-modules', 'javafx.controls,javafx.fxml,javafx.graphics,javafx.base',
'--add-opens', 'java.base/java.lang=ALL-UNNAMED',
'--add-opens', 'java.base/java.util=ALL-UNNAMED',
'--add-opens', 'java.desktop/java.awt=ALL-UNNAMED',
'--add-opens', 'java.desktop/java.awt.event=ALL-UNNAMED',
Where do you have your module-info.java?
* ClickMaster Pro - Modüler JavaFX Uygulaması
*
* Bu modül, ClickMaster Pro uygulamasının ana modülüdür.
* JavaFX, JNativeHook, Jackson ve Logback bağımlılıklarını içerir.
*
* Modül Açıklaması:
* - JavaFX 21.0.2 modülleri (controls, fxml, graphics, base)
* - JNativeHook 2.2.2 global hotkey desteği
* - Jackson JSON işleme (core, databind)
* - Logback logging framework (classic, core, slf4j-api)
* - Java platform modülleri (desktop, logging, management, vb.)
*/
module org.example {
// JavaFX modülleri
requires javafx.controls;
requires javafx.fxml;
requires javafx.graphics;
requires javafx.base;
// JNativeHook - Global hotkey desteği
requires com.github.kwhat.jnativehook;
// Jackson JSON işleme
requires com.fasterxml.jackson.core;
requires com.fasterxml.jackson.databind;
// Logback logging framework
requires org.slf4j;
requires ch.qos.logback.classic;
requires ch.qos.logback.core;
// Java platform modülleri
requires java.desktop;
requires java.logging;
requires java.management;
requires java.naming;
requires java.security.jgss;
requires java.instrument;
requires java.scripting;
requires java.sql;
requires java.xml;
// JDK modülleri
requires jdk.unsupported;
requires jdk.crypto.ec;
requires jdk.security.auth;
requires jdk.net;
// Modül açma izinleri - JavaFX FXML için
opens org.example to javafx.fxml;
opens org.example.ui to javafx.fxml;
opens org.example.ui.components to javafx.fxml, javafx.graphics;
// Modül dışa aktarma
exports org.example;
exports org.example.ui;
exports org.example.ui.components;
}
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?
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() FAILED
3 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?
At line:1 char:44
+ ./gradlew :org.example.ClickMasterApp.main()
+ ~
An expression was expected after '('.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : ExpectedExpression
PS C:\Users\rampa\OneDrive\Desktop\Projects\ClickMaster Pro> ```
oh I just saw that - you would also need to remove that
then it being like this
What options are there in that menu?
I meant in that menu
that is with the main one?
use the one with .main
Using this
Is there a Use classpath of module setting anywhere?
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?
For jpackage, I'd do it similar to https://openjfx.io/openjfx-docs/#modular
Getting started with JavaFX for Java desktop application development
so instead of your custom jpackage command, you would do it somewhat similar to
jlink {
jpackage {
// jpackage options here
// for example
imageName = 'yourAppNameHere'
imageOptions = ['--win-console']
}
}
in your build.gradle
what if
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
mergedModule {
requires 'javafx.controls'
requires 'javafx.fxml'
}
launcher {
name = 'clickmaster'
mainClass = 'org.example.ClickMasterApp'
}
jpackage {
installerType = 'msi'
installerOptions = [
'--win-per-user-install',
'--win-dir-chooser',
'--win-menu',
'--win-shortcut',
'--win-console'
]
}
}
yeah something like that
then
Why that?
mergedModule {
requires 'javafx.controls'
requires 'javafx.fxml'
}
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.
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 supports
honestly, 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:
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
launcher {
name = 'clickmaster'
mainClass = 'org.example.ClickMasterApp'
}
jpackage {
installerType = 'msi'
installerOptions = [
'--win-per-user-install',
'--win-dir-chooser',
'--win-menu',
'--win-shortcut',
'--win-console'
]
}
}
is it work?
Configuration on demand is an incubating feature.
<<<<<<<<<<<
> Task :compileJava
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
<<<
BU─░LD SUCCESSFUL in 4s
8 actionable tasks: 1 executed, 7 up-to-date
jlink build is successful
we can try
Did that generate an msi?
I think you need ./gradlew jpackage though
msi 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?