Is there a way to create native-binary from Jetpack Compose Desktop app using GraalVM?
Asked Answered
B

1

7

I want to create a small binary out of my Compose desktop app. Following are the options out of the box with Compose:

  1. Create native package with java runtime (great, but the size is very big)
  2. Create an Uber (fat) Jar (but it requires Java 11 to run, since Compose library doesn't support older versions)

I believe it is be possible to convert the Uber Jar to native binary using GraalVM. I also tried running native-image command but it created an exe that in turn runs the Jar, which brings back to the same issue; Java 11 has to be installed on the machine. What am I missing?

Boothman answered 14/6, 2021 at 8:11 Comment(1)
See this GitHub issue and this GitHub issueDeception
J
1

Compose for desktop uses Swing in the background, so it is not fully compatible yet with GraalVM's native-image tool.

The latest version of GraalVM introduced experimental support for Swing on Linux, but it is still in development. Presumably once Swing support is stable, Compose should work with native-image.

What is happening in your example is that native-image fails to create the native executable, and instead creates a fallback image, which uses a regular JVM runtime.

Jarman answered 12/7, 2021 at 14:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.