Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
vorburger opened this issue Dec 31, 2023 · 4 comments · Fixed by #1159
Closed

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

vorburger opened this issue Dec 31, 2023 · 4 comments · Fixed by #1159
Labels
build Build, CI, etc. (w.o. #testing) distro Distribution related enhancement New feature or request help wanted Extra attention is needed

Comments

@vorburger
Copy link
Member

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

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

https://www.baeldung.com/jlink

@vorburger vorburger added build Build, CI, etc. (w.o. #testing) distro Distribution related labels Dec 31, 2023
@vorburger vorburger added enhancement New feature or request help wanted Extra attention is needed labels Dec 31, 2023
@vorburger
Copy link
Member Author

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
Copy link
Member Author

https://github.com/bitshifted/launchcode is another tool in this space, see #1157.

jpackage might actually not be a bad idea... jpackage -h shows that it uses jlink itself.

#1159 makes a start! With that, I'm closing this. #1158 has a (low priority) possible future follow-up.

PS: Error: Invalid or unsupported type: [rpm] just means (confusingly) that (on Fedora) you need to sudo dnf install rpm-build. But that's only if you don't specify --type app-image, which is what I really wanted here. (RPM & DEB that are not on and thus autoupdating from a repo are kind of pointless IMHO; an archive, without requiring sudo, seems simpler & better here.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Build, CI, etc. (w.o. #testing) distro Distribution related enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant