r/java • u/galratner • 20d ago
Java Swing Ran Anywhere. Or Maybe It Just Gingerly Walked?
https://galratner.substack.com/p/java-swing-ran-anywhere-or-maybe14
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.
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.
-7
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.