r/javahelp • • Jul 15 '25

JavaFX + jpackage: Reduce startup time using CDS?

We have a lightweight JavaFX Maven project (JDK 21) packaged using jlink + jpackage into an .msi installer.

However, after installation, launching the app takes 4–6 seconds, despite it only displaying a small table (10–15 rows from a text file).

I profiled startup and found most of the time is spent loading JVM base classes. Online suggestions pointed to using CDS (Class Data Sharing) to speed this up.

I tried various ways to integrate CDS with jpackage, but couldn't get it working. The process is quite confusing.

Has anyone successfully used CDS with jpackage? Would appreciate tips or a working pom.xml example.

Thanks!

1 Upvotes

4 comments sorted by

View all comments

Show parent comment

1

u/Puzzleheaded_Ear3790 Jul 15 '25

so if I understand correctly, if I use the --generate-cds-archive with jlink, it will generate a file. Then I have to somehow include this file in jpackage (wix?), and then the jpackage jvm parameters will reference this file?

1

u/milchshakee Jul 15 '25

No, the file is part of the jlink image and is generated at the right place. You don't have to do anything, it will work automatically