#JavaFX error

154 messages · Page 1 of 1 (latest)

marsh loom
#

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.

glad flameBOT
#

This post has been reserved for your question.

Hey @marsh loom! Please use /close or the Close 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.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

dire raft
#

Can you create it with --win-console?

#

How are you using jpackage?

marsh loom
#

I was trying to do it with Cursor AI in order to set it up, I have a Gradle file.

marsh loom
dire raft
marsh loom
#

both

#

but when i run with gradle, it works

dire raft
# marsh loom both

How are you running it without jpackage that you get that error? Are you using a fat JAR? If so, that's the issue

marsh loom
#

I’ve added --win-console to my jpackage Gradle task. Do you want me to send you my Gradle file to check?

dire raft
#

please

marsh loom
dire raft
#

Can you please show the build script/how you are running jpackage?

marsh loom
dire raft
#

Do you have a module-info.java?

marsh loom
#

cursor removed it

#

ill add now

dire raft
#

oh you are doing it manually with the JavaFX SDK...

dire raft
#

yeah that is far from ideal

#

JavaFX wants to run with a module-info.java

marsh loom
#

Yesterday I tried every possible way, I even downloaded the JavaFX SDK, but the same error kept happening.

#

now i added module-info.java

dire raft
#
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

marsh loom
#

My project is classpath-based, so Cursor removed the module-info.

dire raft
marsh loom
#

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

dire raft
#

ok yeah that should probably be fine for the most part

marsh loom
#
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

dire raft
dire raft
marsh loom
#

now i see nativehook is on the classpath, not the module-path

dire raft
#

it should be on the modulepath

#

all dependencies should be in the modulepath

marsh loom
#

im trying

dire raft
#

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

marsh loom
#

i use gradle 8.5

dire raft
#

so you need to use jnativehook 2.2.2

marsh loom
#

allright i will use jnh 2.2.2 version

marsh loom
#

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

marsh loom
#

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```
dire raft
#

Also why are you using jdk.unsupported?

#

And also java.desktop, java.management, java.naming, java.scripting, crypto/security modules and many others?

marsh loom
# dire raft Wha happens when you run the project now?

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

dire raft
#

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?

marsh loom
#

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.

dire raft
dire raft
#

also modularity issues can be complicated and being stuck at these for a long time is normal ;)

marsh loom
dire raft
#

Is JavaFX on your modulepath in your IDE?

dire raft
#

Can you show the full text shown in the console?

#

I think IntelliJ should show the full command at the start

marsh loom
#

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
dire raft
#

oh right IntelliJ just runs Gradle

marsh loom
#

yes i can only run this project with gradle

dire raft
#

Does the same issue occur when running it from the command line with Gradle?

marsh loom
#

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

dire raft
#

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?

marsh loom
#
 * 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

dire raft
#

Does gradlew run still work?

marsh loom
#

yes it works

dire raft
#

Does it also work if you remove the entire jvmArgs = [ ... ] block?

marsh loom
#

lets try

#

it works

dire raft
#

Can you show the run configuration in IntelliJ?

marsh loom
dire raft
#

Can you remove the JVM args from it?

marsh loom
#

like this?

dire raft
#

yes

marsh loom
#

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()'.

dire raft
#

Can you remove the run configuration and restart it?

marsh loom
#

i start with current file

#

and again...

dire raft
#

Can you run gradlew :org.example.ClickMasterApp.main()?

#

Does that do anything?

marsh loom
#

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> ```
dire raft
#

oh I just saw that - you would also need to remove that

marsh loom
dire raft
#

What options are there in that menu?

marsh loom
#

and the main class

dire raft
#

I meant in that menu

marsh loom
#

if i select clickmaster_pro.main

dire raft
#

yeah it should be that one

#

but the -cp looks wrong

marsh loom
dire raft
#

that is with the main one?

marsh loom
dire raft
#

use the one with .main

marsh loom
dire raft
#

Is there a Use classpath of module setting anywhere?

marsh loom
#

here's the all menu

#

i think there isnt or i couldnt see

dire raft
#

and it works with none of the options?

marsh loom
#

I tried every setting, but nothing worked.

dire raft
#

Can you remove the run configuration and just start it again?

marsh loom
#

oh i find a way

#

when i do this it works

dire raft
#

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

marsh loom
#

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'
        ]
    }
}
dire raft
#

yeah something like that

marsh loom
#

then

dire raft
#

Why that?

    mergedModule {
        requires 'javafx.controls'
        requires 'javafx.fxml'
    }
marsh loom
#

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.

dire raft
#

but why are you using it here?

#

Also I asked you and not your LLM

marsh loom
#

because I didn’t want the user to get an error after installing the setup via .msi

#

and i trying some ways

dire raft
#

that mergedModule setup is definitely not something JavaFX supports

marsh loom
#

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

dire raft
dire raft
#

I think you need ./gradlew jpackage though

marsh loom
#

msi file created but still isn't working. but ill try some way now.

dire raft
#

What happens when installing the msi and then running the installed app from the console?