r/java • • Oct 10 '26

JDK team is working on creating a single-native executable image using jlink

https://youtu.be/fXBGBovpH88?t=622
147 Upvotes

63 comments sorted by

View all comments

Show parent comment

16

u/pip25hu Oct 10 '26

I don't think 10 vs 35 MB mattered for desktop applications for a long time now. Also, when most applications come in installers and packages, why is a single file such an advantage? 

11

u/0x07CF Oct 10 '26

Deploying a single binary is much easier than having to prepare an environment.

7

u/dmigowski Oct 10 '26

Think about small command line tools

5

u/pip25hu Oct 10 '26

Even in Unix-like operating systems where those tools are the most used, they come from packages.

-10

u/dmigowski Oct 10 '26

whatever you say, bro

12

u/emberko Oct 10 '26
  • User: Here is my small app written in Rust/PyQt/Gtk. It's just a simple format converter with a couple of buttons. It uses 30 mb RAM. I tried using Java, but it uses 100-150 mb RAM. I feel it's too much for this task. Can I reduce it?
  • Java dev: <Very long speech about GC trade-offs, followed by a lecture about the right ways to measure memory footprint, ended by a dozen of obscure JVM keys recommendations>.
  • User: goes away.
  • Java devs: Huh? But Java is so coooool. Why is that?
  • User: My app is just a single binary of 10 mb size. It's very easy to distribute, so I decided to write several small utils I can share with my friends and colleagues.
  • Java dev: You can use jlink to create a custom image. It's about 60 mb, but it's nothing nowadays, buy yourself a larger SSD or something. And just tell your friends to run it from yourapp/bin/. Or you can give them a JAR, it's very small and convenient. What do you mean they don't have Java installed? Just tell them to download it. What do you mean which vendor? Just tell them any vendor. What do you mean which version? The version you compiled it with, dumbass. What do you mean they have to reinstall Java if you compile it with a newer version? Of course they do! It's just 200 mb, and I already told you disk space is cheap and matters nothing, so stop bothering me with these questions.
  • User: goes away.
  • Java devs: Huh? But Java is so coooool. Why is that?
  • User: My app starts in 0.5 sec, which is kinda important for a small utility. Can I keep this time in Java?
  • Java dev: (stroking his beard) Well, if you ask me, startup time is only important in microservices. You can absolutely wait a couple of seconds more, but if you insist, you can enable CDS cache, it makes your app start 10% faster. So, it's 1.8 sec instead of 2 sec. Cool, isn't it? What do you mean not really? Then compile your own AOT cache, you ungrateful bastard. It adds 50 mb to your dist size, but I already told you the disk space is cheap.
  • User: goes away.
  • Java devs: Huh? But Java is so coooool. Why is that?

I don't say Java is bad, I'm all about choosing the right tool for the job. Java is the enterprise king for web apps. For everything else, choosing Java is asking for problems. You can very much see this as Java apps prettyy much not being present on either the desktop or CLI public market (except development tools maybe), and I'm glad OpenJDK decided to put some efforts into improving that.

14

u/pron98 Oct 10 '26 edited Oct 10 '26

You need to remember that this same "user" (who's really a developer) also writes their GUI apps in Electron, and this isn't about matching different consistent expectations, but trends on online developer forums that have nothing to do with well-considered tradeoffs or an understanding of computing. Do you really think that if we drastically increased language complexity and build times but reduced nominal RAM consumption to match that of Rust, Java would become the talk of the town on these forums?

Now, I do agree that Java makes some tradeoffs that make it less attractive for small CLIs but more attractive for larger applications, whereas Go and Rust make the opposite tradeoffs. If there were a language that's optimal for both, that would have been perfect, but there isn't one.

You also have to remember that the only language with more dominance than Java in the world right now is JavaScript/TypeScript (and Python is about the same as Java). All other languages are doing far, far worse (and that's because different software has different market sizes; that of small CLIs is very small, but it's overrepresented on developer forums because developers use small CLI tools a lot, and are pretty much the only ones who do). So to those who say that Java should make the same tradeoffs as other languages to do better, unless they're talking about JS/TS, then they should really read more market reports and less HN/Reddit.

Still, I wouldn't say that using Java "for everything else is asking for trouble". I think the tradeoffs Java makes are more balanced than other languages (and especially when you take into consideration the respective market size of different domains). Using TS or Go or Rust for large apps is more painful than it is to use Java for, say, CLI apps, and large apps make up a share that is many times the size of that of CLI apps. Also, when it comes to desktop apps, the choice made by that "user" shows just how unusual that user is, because the overwhelming majority of desktop apps that aren't bundled with the OS use some web tech like Electron, and if you also include apps written using the OS's native toolkit, everything else makes up an almost negligible share. Java isn't a big player in desktop apps, but Python and Rust certainly aren't, either (they're possibly smaller players than Java, although Java desktop apps are mostly company-internal ones, and those others are mostly aimed for developers). Also, 100MB is ~0.6% RAM (on the average user's hardware; half that on the average developer's hardware), and if you think the average user cares about or is impacted by a difference of 0.6% RAM, then unless you only develop software for other developers, maybe you should talk to real users more and to hackers less (BTW, do you care about a 0.6% difference in CPU as much as you do about a 0.6% difference in RAM? If not, you should because CPU is far more expensive than RAM).

So when comparing Java to other languages without including the only one that's more popular than Java (and suffers from the same shortcomings you mention) and you do include languages that are more popular than Java only in developer tools and far less popular than Java anywhere else, you might have an observational bias, because developers make up an almost imperceptible minority of software users.

6

u/senseven Oct 10 '26

That is the reason we had Java and Python and Go and C#. Because Java was the enterprise, Python was fire and forget prototyping, Go came in with kubernetes and C# was whatever you needed to do to run stuff on Windows. The corpo uses it also on mobile for the apps, team was there and we didn't want to learn also Kotlin and Swift.

We have a tug of war between go and c# with the system tools. Modern container Java is rock solid at the enterprise level. We kicked out most of python, only to get Node+typescript through the the back door. Its always people who refuse to use go or c# for reasons. Microsoft goes hard with AOT C# that gets you small executables, they are also vying for go's low overhead one exe world.

4

u/trydentIO Oct 10 '26

Which of the most widely distributed web-based desktop apps is under 100 MB? Spotify, 1Password, Teams, Postman, Hopscotch, Podman/Docker Desktop, and so on? I also wonder which final users you mean, since none of these applications is under 10 MB. I suspect that when we talk about desktop applications or standalone executables, we don't think of the same target people or finality.

Java isn't that present in the desktop arena because of marketing; Oracle affected that forever, and it has nothing to do with Java's capabilities or the problems you're talking about.

But let's say this more clearly than hiding behind an excuse: on other platforms, standalone executables and desktop apps get more traction and are more attractive.

5

u/pron98 Oct 10 '26

No one is really present in the desktop arena except JS/TS (plus some non-negligible but small presence of OS-native toolkit apps).

1

u/trydentIO Oct 10 '26

Indeed! And no one seems interested in proposing a better alternative.

5

u/pron98 Oct 10 '26 edited Oct 10 '26

You're talking about an alternative to a now-incumbent that beat Microsoft, Adobe, and Apple at their own game (never mind Java) and is now controlled by Google (with Microsoft as followers). You can see why companies are hesitant.

2

u/pjmlp Oct 12 '26

Even though it isn't JavaTM proper, people routinely forget Android is heavily based on Java ecosystem, so no it isn't only Web apps.

Even if it is a subset of Java 17 LTS, and nowadays Kotlin gets the spotlight, Android Studio, Gradle and Kotlin tooling run on top of the JVM, and even with ART, most libraries come from Maven Central, in a mix of Java and Kotlin sources.

0

u/OwnBreakfast1114 Oct 13 '26

Here is my small app written in Rust/PyQt/Gtk. It's just a simple format converter with a couple of buttons. It uses 30 mb RAM. I tried using Java, but it uses 100-150 mb RAM. I feel it's too much for this task. Can I reduce it?

Who the hell is this aimed at? The last time I looked at/cared about resource consumption for random utilities was >10 years ago. Maybe the author is trying to reduce usage, but the "customers" of this utility probably don't care whatsoever.

Not only do the consumers not care, do you really think people using utilities are comparing it with hypothetical utilities in other languages? No, they're just using whatever solves their problem. People used to (and people probably still do) use full blown windows installers to convert image formats. Nowadays nobody cares because everything is in the cloud anyway.

This entire set of scenarios is a developer writing a utility for another developer who is complaining that the first developer could have done better on a pure absolute scale since 10mb vs 30mb is irrelevant on any device people actually use. It's like a code golf exercise or the nit-pickiest of complaints.

-2

u/unknowinm Oct 10 '26

I wonder why it’s so difficult to compile a java file to native…might be an interesting side project for claude…any idea what would be needed? Not building a compiler from scratch but using something like LLVM or something. It’s difficult because of reflection? Other languages don’t have reflection?

2

u/koflerdavid Oct 11 '26

Please read up on the tradeoffs GraalVM imposes on native applications. You will see why it is indeed not straightforward at all. That being said, there are other possibilities that could be harnessed, at least on Linux: AppImages.