Native Java applications with GraalVM on Xperia 10II

Just a quick report:

I thought that maybe with the 64bit build of SFOS on the Xperia 10 II the aarch64 support of graalvm is usable.
Aaand it is:

Howto:

  • Download and un-tar the graalvm distribution following their install instructions.
  • install glibc-devel zlib-devel gcc
  • compile sample java file (here: Run.java) with <graalvm>/bin/javac Run.java
  • test it with <graalvm>/bin/java Run
  • install native image with <graalvm>/bin/gu install native-image
  • create native image with <graalvm>/bin/native-image Run
  • wait
  • execute with ./run

In my example the resulting image is 9.2mb.

1 Like

I tried to find a way to get an example with javafx to run, but I couldn’t find any.

What works is, to use the dbus to communicate with a qml frontend.
A java application can send and receive messages with java-dbus. This application can be distributed as a native image. A QML app can start this application and interact with it via dbus.

Next time I come up with a good fitting application idea I gonna try to create an example.

As I understand the official store restrictions, such an app wouldn’t be allowed in harbour, as the java app is not a library, but a standalone application.

I added the java-dbus dependency with maven. Maven can be installed by just downloading it from the webpage and setting JAVA_HOME.

I tested the java application with dbus-monitor to listen to the dbus.

(unresolved problem: native-image doesn’t like slf4j in this example, but it works as (fat-)jar)