Does anyone know how difficult it would be to use ...
# announcements
s
Does anyone know how difficult it would be to use Kotlin to create a standalone JVM application and ship it? I believe a few years ago the JVM added a way to ship your application so that it could run without requiring a JVM installed on the client machine. I've just never done it before.
t
You could look at webstart or JNLP or whatever it's called these days.
or are you talking about kotlin native? compile to a native executable?
s
I'm talking about JVM
b
Just compile kotlin app to graalvm native image
s
Is JNLP for running java applications in browsers? If so - it's not what I'm looking for. I want a java application that someone can download and install, but I don't want to have to force that they have separately installed a JVM on their machine somewhere. I'd like to package everything together in a single executable that is a standard exe on windows, and a standard .app on mac. I thought jigsaw from Java 9 might have allowed something like this, or I thought I read something else about this somewhere.
@Big Chungus I'm not sure what
graalvm native image
is. I'll have to read about it. Based on my further explanation that I just posted, do you think it's something I'd be interested in?
Graalvm works as a replacement to JDK & JRE. Native image packaging essentially analyses your java bytecode (as such all jvm languages are supported) and then produces a native AOT executable with all jvm and source ddependencies.
So you get exe, sh or app instead of jar
Benefit of this over fat jar is that it does not require jre anymore and has instant boot time and very low memory footprint
But it sacrifices a bit of latency and top performance a bit (i think there's a graph comparing AOT and JIT modes in that link somewhere)
But it looks to be exactly what you're looking for
s
Slightly separate question: If I were to use this for a java application, are there any services for collecting crashes etc from the client, similar to crashlytics for mobile? I'm kind of used to the Mobile world, and I've never really thought about shipping any java desktop applications before.
b
I'm sure there's a java lib for that, but I've never needed one myself so can't recommend anything
Also just to be clear, graalvm native image doesn't restrict you in terms of how you utilise jvm ecosystem. So in essence, any jar app can be compiled to native image. The only difference is that you need to configure reflection beforehand, similar to android proguard
Have you checked tornadofx? It's kotlinized javafx and they provide a lot of these desktop app specific utilities like updates and i think even crash reporting
You could then either pack it to the installer using their plugin that'll install jre and your app for the user, or just compile it to graalvm native image
s
Yeah, I know about tornadofx. I'm planning on using it :)
Thanks for everything
m
I can attest to both TornadoFX and GraalVM Native Images to be great things, but that won't work. GUI apps cannot be compiled to a Native Image (unless something changed in the last month).
s
@Marcin Wisniowski really? Why's that?
m
I don't remember the details, but JavaFX references things that cannot be compiled by GraalVM. But take a look at Gluon Substrate, which can do this. I have not tried it though.
a
@Marcin Wisniowski It seems like Gluon Substrate uses GraalVM in some capacity as well.
m
Yes it does. : ) I was imprecise, I meant GraalVM by itself won't compile JavaFX apps.
m
I have tried Gluon Substrate. I was able to get a simple TornadoFX app to compile and run: https://github.com/maroc81/WeatherPikt/
🎉 1
The binary was almost 200MB though
😕 1
I tried to get a more complex TornadoFX app I wrote for work and ran into many problems due to the way Kotlin creates inline class files and such
Eventually I gave up and went with jpackage
I now have an msi installer for windows, .deb for linux, and .dmg for mac
a
@Marshall how's the sizes with jpackage?
m
for a Java Swing and JRE 11, the MSI is around 35MB and installed is around 60MB
for a TornadoFX App, also JRE 11, the MSI is around 60MB and installed is around 87MB
a
Okay that's not too bad I guess, compared to electron sizes and the lot. I guess qt would be the best solution for size but their license is so restrictive
m
With qt if you're building static executables those will still be in the 30 MB range or so unless you remove localization
Not to mention the hoops you have to jump through to get a static build
a
That's around half the size of tornado though. I still think 80MB is pretty acceptable on desktop these days.
m
On desktop, that is practically nothing in my opinion, especially compared to some mobile apps these days
👍 1
m
And here I spent 2 days optimizing my Android app size from 7MB down to 5MB...
b
@Marcin Wisniowski Why'd you need to optimize the size for such a small app? Just curious for the use-case
m
I don't need to, I just don't want it to take too much space on the user's phones or download longer. And that's a better install experience, plus less chance it's picked up for uninstalling when the user is freeing up some space.
b
Got it. Thought there were some implications to do it from android side