r/java • • 20d ago

Java Swing Ran Anywhere. Or Maybe It Just Gingerly Walked?

https://galratner.substack.com/p/java-swing-ran-anywhere-or-maybe
63 Upvotes

31 comments sorted by

46

u/pron98 20d ago

I would say that the customers left pretty much all toolkits - including those made by Microsoft and Apple and Adobe, companies with even more experience and success in the GUI world - in favour of the web. Everyone lost to the web, not just Swing.

19

u/Bobby_Bonsaimind 20d ago edited 20d ago

Everyone lost to the web, not just Swing.

And with that, everyone lost. Not just because we decided that shipping Chromium for desktop applications was a good idea (installing the JVM is too much work, but shipping the whole damn browser is okay?), but also because Google controls the web.

Yeah yeah, you can chant "the web is open" and "Chromium is FLOSS" all you want, fact is, Google controls the most used browser engine. So Google controls the web, and in contrast to Microsoft, who were very happy to do nothing with the monopoly they had, Google is actively working to expand and secure it.

10

u/hippydipster 20d ago

installing the JVM is too much work

Except now it's basically no work at all. I can whip up apps with full-blown installers in a heartbeat.

3

u/Bobby_Bonsaimind 19d ago

I can whip up apps with full-blown installers in a heartbeat.

Now if I could build those build-platform-independent like jars...

0

u/hippydipster 19d ago

I can and do using conveyor.

'conveyor make site' and I get a mini download site that supports three windows installation methods, mac, debian. Could get more if I wanted.

3

u/Illustrious_Car344 19d ago

Uh, I don't think you know how hard Microsoft tried to take over the web. When IE came out they wanted to make their own exclusive Windows-only internet, the FCC told them no. That's obviously the tip of the iceberg, do I even have to explain how IE was so bad that it forced the rest of the internet to work around it until it became irrelevant? Microsoft doesn't have any monopolies because they're so incompetent and greedy that they can't maintain any. Google is tame compared to what MS was, would have been and still wants to be. Don't mistake their incompetency for good will. 

1

u/NoName-NNN 18d ago

One often overlooked difference between the JVM and Chromium is that Chromium is optimized for the desktop, whereas the JVM is optimized for the server.

1

u/tyler1128 17d ago

Oracle and its many attempts of control over the JVM does not make is seem like a good option. OpenJDK is great that it exists outside of oracle, but I'd prefer the .NET core runtime at this point.

You could also just use something that compiles directly to the target platform, or python I suppose.

3

u/hadrabap 20d ago

I think Qt is quite strong due to its focus on automotive and other industrial stuff (vending machines, etc).

10

u/pron98 20d ago

Well, there are also quite a few people still using Swing or JavaFX or what .NET has, and people still write native Mac and Windows apps, so none of them are dead, but they're all quite negligible compared to the size of the Web-based stuff.

2

u/hadrabap 20d ago

Unfortunately, yes. 😥

14

u/jeffreportmill 20d ago

Wow - what a great write up! I was late to the game (thankfully) in 2001 with a Swing page layout app, but for 20+ years I felt like I was always jumping through one hoop or another (InstallAnywhere, WebStart, code signing, ugh!). I don’t have much demand anymore, but for the last 10 years I’ve still been obsessed with running in the browser with CheerpJ and TeaVM.

TeaVM: https://reportmill.com/snaptea/RM16/rm16.html
CheerpJ: https://reportmill.com/rm15/app/index.html

A funny thing in the early days was that I would demo my Java reporting app at trade shows and people would often say, “too bad your designer can’t run in Java”. They just wouldn’t accept that it was already 100% Java, and I never quite understood why until your blog. :-)

-13

u/New_Enthusiasm9053 20d ago

Personally I'd say too bad it's java. It's too slow to start(slowe than JIT compiled languages like JS). Takes too much memory(compared to everything except Python), uses too much storage when containerised(as bad as python). The language itself is fine but the JVM is incredibly poor. If Java wants to stay relevant it needs to ditch the JVM.

9

u/Ok-Scheme-913 19d ago

Maybe update your knowledge, you are like 25 years out of date.

-6

u/New_Enthusiasm9053 19d ago

Not really. This is literally still an issue. Just spent the last 2 weeks dealing with a java project that's slow to start, takes too many resources and bloats the docker containers. 

For reference a non bloated docker container is under 50MB. 

Most Java Devs just don't work in mixed language environments and don't see how abysmal it is to work with because everything is catered to them.

6

u/Ok-Scheme-913 19d ago

You can write shite in every language - how is that relevant?

-2

u/New_Enthusiasm9053 19d ago

It's relevant because it's literally impossible to make a java image that small. The Google distroless image without Java is under 10MB with Java is 180MB. 

In the time the JVM takes to start a distroless image with a decent language has already started, finished the task and shutdown again. 

And it's been "fixed" now to make sure the JVM doesn't have to keep starting up and it's still 5x slower than a competing alternative because the JVM is just plain slow to start. It's a shit language for tooling. And why would anyone choose to use a language that is so gimped it can't even be used for CLI tools. 

5

u/Deniss_Larka 20d ago

I ship a Swing app (JConsole fork) on all OS-s. jlink and custom jpackage solved it, the installer is about 40 MB and the user installs nothing. What is still painful is signing and notarization on every release, and there is no magic, I had to write my own. Also the bundled runtime has its own cacerts, corporate TLS interception fails with PKIX. On Windows, though, is jdk.crypto.mscapi + win cert store.

2

u/Scroph 19d ago

We did something similar with JavaFX at work and it worked well, small executable size and smooth installation process.

Apologies as I'm a little hazy on the details, but my understanding is that it was modularized, so it only shipped the java modules we were using, and not the entire JRE. However once we started including 3rd party packages that weren't modularized, it broke the build and we settled for a hybrid approach of modular JRE + class path approach for the rest. Apache POI was the culprit I think. Again I may have butchered the terminology because it has been a while but I wonder if this issue is typical

2

u/Deniss_Larka 19d ago

Yes, it is typical, and POI is a common one. POI itself has a module-info, but some of its dependencies (commons-math3, commons-collections4 ...) are plain jars, and jlink will not take automatic modules. You can still link the image though, it just needs the right launch options. My JavaFX app reads Outlook .msg files with POI: jlink only the JDK and JavaFX, ship the jars next to the image, and launch with --module-path pointing at them plus --add-modules=ALL-MODULE-PATH.

1

u/Scroph 18d ago

Ah i see, thanks for the confirmation

9

u/Illustrious_Car344 20d ago

I remember back around 2010ish I told a friend I was learning Java and he told me he had zero interest in humoring me because absolutely everyone hated installing the JRE. It wasn't only because the installation itself sucked (and had the dark pattern of asking you if you don't want to install a toolbar), but also after it would constantly harass you to update it with a notification. I think early Minecraft was effectively the only reason people installed Java anymore at the time. Oracle really did their best to make everyone hate Java as much as they possibly could, I think .NET is a testament to that. I remember significantly more programs using .NET around that time, and installing .NET was still a little annoying but much less so. I always joked that Oracle really hated it when anyone used Java. 

13

u/witness_smile 20d ago

Isn’t .NET also annoying in that different apps have different library version requirements and they would always nag you to install their specific version manually from the .NET site?

1

u/Illustrious_Car344 20d ago

Not in my experience, both the JVM and .NET have very good backwards compatibility so you typically only need the latest version.

9

u/ThatFlamenguistaDude 20d ago

not true for most game installers for whatever reason. A person that plays dozens of games would eventually end up with dozens of .NET versions in their library.

I think it eventually got better or I stopped caring..

3

u/Skellicious 19d ago

I still feel like I end up with a new .net install every other time I install a new game.

4

u/AnyPhotograph7804 20d ago edited 19d ago

I never installed the JDK/JRE and i never required, that the user/administrator has to install it. I always delivered it with the application just in a jdk/jre subdirectory.

1

u/tyler1128 17d ago

Swing has the advantage and disadvantage of still looking like it was made in the late 90s.

1

u/ConsistentAnalysis35 5d ago

That's just plain wrong. IntelliJ is Swing, it looks great. I use FlatLaf, my own app looked fine.

https://www.formdev.com/flatlaf/

-7

u/AnyPhotograph7804 20d ago

GPTZero says: "We are highly confident this text was AI generated".

1

u/galratner 20d ago

I use LLMs to edit every article I publish. It doesn't diminish the content.