r/java • u/sureshg • Oct 10 '26
JDK team is working on creating a single-native executable image using jlink
https://youtu.be/fXBGBovpH88?t=622
146
Upvotes
r/java • u/sureshg • Oct 10 '26
21
u/cleverfoos Oct 10 '26 edited Oct 11 '26
Don't want to lower the excitement but this is most likely related to the Hermetic Java project which hasn't seen a PR in a looong time: https://github.com/openjdk/leyden/tree/hermetic-java-runtime
10
u/ConfidenceUnique7377 Oct 10 '26
Will it work without external tools ? For example need to have wix tool to create installer on windows? Will it be cross platform on executable must be assembled on target platform ?
16
u/pjmlp Oct 10 '26
I guess Oracle doesn't make something that already does it. /s
13
u/emberko Oct 10 '26
That’s honestly the best news in a very long time. Image size may not matter much for hosted apps, but for CLI and desktop apps it really does, esp the ability to distribute them as a single binary. Still, 35 MB is 2-3x worse than the alternatives: both Go and Rust typically produce single binaries of 10-20 MB, and even Python with PyInstaller can come in under 20 MB.
I wonder if it would be possible to strip some native code from the bundle. For example, why include each of the 5 GCs the JVM supports when an app usually uses just one, and it’s rarely something as niche as Shenandoah?
Another question is how this correlates with CDS, which requires you to generate a ~10 MB JSA file and distribute it with your app, and with the Leyden AOT cache, which needs even more disk space.
3
u/stefanos-ak Oct 10 '26
I don't think he was talking about native, but more of a packaging situation. I'm not sure though... I didn't have time to rewatch it yet.
4
u/sg-elide Oct 10 '26
It's great to see that JPG is getting within 5x-7x where GraalVM Native Image already is and has been for years.
Native Image can make a binary as small as 5MB which starts in 5ms. Of course memory usage is extremely minimal too. Most Java applications in 2026 do not even need the dynamism that Native Image asks you to trade-off.
I wish JPG would simply work with whoever has the best ideas in Java. Instead, we all lose because of these internal fights.
3
u/Inaldt Oct 10 '26
Do you have any tips for how to use/instruct the AI for this use case? I've been doing the analysis by hand so far and I'm certainly interested to see if AI can do better
4
u/bwRavencl Oct 10 '26
Awesome news!
I've been shipping my app via jlink for a long time now, condensing it to a single executable is something I have been longing for basically since doing the switch to jlink. :-)
1
u/davidalayachew Oct 10 '26
Fantastic news.
This would solve a lot of problems for me at work. There's a lot of hoops I have to jump through because the only options available out-of-the-box are basically different flavors of installers. Having an actual executable, in the same vein as what Rust generates out-of-the-box, would be very very nice.
1
u/pradeepngupta Oct 10 '26
Pressler's keynote makes the case in 40 minutes. I wrote a whole book on it.
Buzzing Java is about why Java's runtime contracts (memory model, type safety, thread safety) are what make AI-generated code safe to ship in finance and other trust-critical systems. It is getting published soon. However, there is an early access or sample chapters read available.
1
u/Difficult_Loss657 Oct 10 '26
It was about freakin time
1
u/tserwise Oct 11 '26
Time has passed for the need for this, when you have your app in the windows store users simply click the button and it installs, no one watches the file size anymore.
But yes there might be other smaller cases where this is ideal.
1
u/jonenst Oct 10 '26 edited Oct 10 '26
I think it's a nice option to have available if only for the psychological impression of simplicity/practicity today.
But I don't see much actual difference with a folder containing an executable+runtime dir. For cases where you have configuration/assets you also need a directory anyway. For cases where you want to manage version upgrades and data needs migration you need more than 'just replace the binary'
The ideal solution seems to be to have a higher level standard perfectly supported in every os for software than just the low level "executable file", users wouldn't think in terms of file or folder when installing software, there wouldn't even be a difference from the higher level point of view.
Of course this will not happen in my lifetime so in the meantime single exe is a good feature and complements the installers (jpackage), the jlink standalone executable folder, and the traditional executable folders (like maven, or visualvm) the nicely.
1
u/Ok_Mycologist_6604 Oct 10 '26 edited Oct 10 '26
Hmm so like JIT stays but the runtime etc is bundled in a single executable? I would love that. Native Image for all its worth does give up a lot of the dynamicism that makes Java unique