Executable for JavaFX Modular CLI sample application built on Windows 11 with GraalVM 22.0.1+8.1 failed to run
Discussed in https://github.com/oracle/graal/discussions/9166
Originally posted by OlexYarm June 23, 2024 I built executable (native image) on Windows 11 for JavaFX Modular CLI sample application with Oracle GraalVM 22.0.1+8.1 (build 22.0.1+8-jvmci-b01). I failed to run with error below: Exception in thread "main" java.lang.RuntimeException: java.lang.ClassNotFoundException: hellofx.HelloFX at javafx.graphics@22/javafx.application.Application.launch(Application.java:311) at hellofx/hellofx.HelloFX.main(HelloFX.java:23) Caused by: java.lang.ClassNotFoundException: hellofx.HelloFX at org.graalvm.nativeimage.builder/com.oracle.svm.core.hub.ClassForNameSupport.forName(ClassForNameSupport.java:143) at org.graalvm.nativeimage.builder/com.oracle.svm.core.hub.ClassForNameSupport.forName(ClassForNameSupport.java:106) at [email protected]/java.lang.Class.forName(DynamicHub.java:1387) at [email protected]/java.lang.Class.forName(DynamicHub.java:1377) at javafx.graphics@22/javafx.application.Application.launch(Application.java:299) ... 1 more
Step to reproduce
- Install required software (Oracle GraalVM 22.0.1+8.1, OpenJFX 22 for Windows x64, Git 2.45.x, Git Desktop 2.50.x).
- Open Windows Command Prompt
- Clone JavaFX samples from GitHub (with Git or Git Desktop) cd / gh repo clone openjfx/samples
- Build JavaFX Modular CLI sample application according to README.md cd CommandLine\Modular\CLI\hellofx set PATH_TO_FX="C:\openjfx-22_windows-x64_bin-sdk\javafx-sdk-22\lib" dir /s /b src*.java > sources.txt & javac --module-path %PATH_TO_FX% -d mods/hellofx @sources.txt & del sources.txt
- Run sample application for testing java --module-path "%PATH_TO_FX%;mods" -m hellofx/hellofx.HelloFX
- Run sample with GraalVM agent for creating reflection, etc. config files java -agentlib:native-image-agent=config-output-dir=native-image --module-path "%PATH_TO_FX%;mods" -m hellofx/hellofx.HelloFX
- Build native image with native-image tool native-image --verbose --native-image-info -H:+UnlockExperimentalVMOptions -H:+BuildReport -g --no-fallback --module-path "%PATH_TO_FX%;mods" -m hellofx/hellofx.HelloFX --class-path "mods" -o jfxHello
- Run native image jfxHello.exe