enola-dev / enola

Enola 🕵🏾‍♀️ Holmes was an SRE.
https://docs.enola.dev/
Apache License 2.0
16 stars 5 forks source link

Build (and publish) a `jpackage`-d "native" (not really) executable #391

Open vorburger opened 9 months ago

vorburger commented 9 months ago

https://www.baeldung.com/java14-jpackage

https://www.baeldung.com/jar-windows-executables

https://www.baeldung.com/jlink

vorburger commented 8 months ago

https://medium.com/azulsystems/using-jlink-to-build-java-runtimes-for-non-modular-applications-9568c5e70ef4

vorburger commented 3 months ago

I've dabbled with this a bit today, something like this actually works:

$ ~/.cache/bazel/_bazel_vorburger/a3c...bf4/external/remotejdk21_linux/bin/jlink \
        --no-header-files --no-man-pages --compress=zip-9 --strip-debug \
        --add-modules java.logging,java.xml --output site/download/latest/jre

$ site/download/latest/jre/bin/java -jar bazel-bin/java/dev/enola/cli/enola_deploy.jar -V

$  du -h site/download/latest/jre/
43M

Note that this smaller JRE does NOT (seem to) improve JRE boot start-up speed; it actually seems to be slightly slower, for some reason, for me:

$ time ~/.cache/bazel/_bazel_vorburger/a3c...bf4/external/remotejdk21_linux/bin/java -jar bazel-bin/java/dev/enola/cli/enola_deploy.jar -V
~240ms

$ time site/download/latest/jre/bin/java -jar bazel-bin/java/dev/enola/cli/enola_deploy.jar -V
~310ms

BTW jpackage apparently only builds (a DMG or PKG for Mac, MSI or EXE for Win, or) DEB and RPM - that's not the point of interest, here. (That should be done by distros.)

As far as I understand, there isn't really any way to "build (and publish) a jpackage-d (not really) 'native' executable".

What could be done with this is to re-distribute such a minimal JDK together with the (existing) single JAR.

This could be in different (and possibly several) formats, including:

vorburger commented 3 months ago

https://stackoverflow.com/q/61612710/421602 FYI

https://appimage.github.io/apps/

An AppImage is fun because it can include an icon, and importantly a .desktop with which we could ./enola server && xdg-open http://localhost - neat!

https://github.com/AppImage/AppImageKit/wiki/Bundling-Java-apps

https://docs.appimage.org/packaging-guide/manual.html

https://docs.appimage.org/introduction/software-overview.html#ref-appimagetool

https://docs.appimage.org/packaging-guide/from-source/linuxdeploy-user-guide.html#ref-linuxdeploy

https://github.com/probonopd/go-appimage ?

https://docs.appimage.org/packaging-guide/testing.html#using-the-docker-based-appimage-testsuite