Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/steve-perkins/jlink-demo
A demo of using Java 9 modularization, and the JDK's new `jlink` tool, for zero-dependency deployments
https://github.com/steve-perkins/jlink-demo
Last synced: 3 months ago
JSON representation
A demo of using Java 9 modularization, and the JDK's new `jlink` tool, for zero-dependency deployments
- Host: GitHub
- URL: https://github.com/steve-perkins/jlink-demo
- Owner: steve-perkins
- Created: 2017-10-10T21:30:50.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-10-19T21:04:21.000Z (over 7 years ago)
- Last Synced: 2024-08-02T01:26:59.707Z (6 months ago)
- Language: Java
- Size: 75.2 KB
- Stars: 144
- Watchers: 12
- Forks: 10
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Using `jlink` to deploy native(*) Java applications
===================================================
A demo of using Java 9 modularization, and the JDK's new `jlink` tool, for zero-dependency
deployments. That is, application bundles suitable for native(*) execution, with the Java runtime
embedded.Unlike [older](http://launch4j.sourceforge.net/)
[approaches](https://docs.oracle.com/javase/8/docs/technotes/guides/deploy/packager.html),
which required embedding basically an entire JRE (around 200+ megs), the `jlink` tool allows you to
strip down the embedded runtime to include only those portions of the standard library that are
absolutely necessary.> (*) No, this is not "native" in the C/C++ sense of AOT compilation. There is still a Java Runtime
Environment executing the code. However, the code is packaged up into a deployable bundle, with a
JRE and launch script native to the specific target platform (i.e. UNIX shell or Windows batch). No
other software needs to be installed, and the end user experience is no different from an application
shipping with Qt or GTK shared libs.Results
-------
This repository contains a Gradle multi-project setup, with two sub-projects. One is a basic "Hello
World" command-line application, and the other a JavaFX app. These are the resulting sizes of the
native application bundles that are generated, both raw as well as after being compressed with 7-zip,
on a 64-bit Windows system (with Electron for comparison):App | Compressed with 7-zip | Raw Size when deployed
----- | --------------------- | ----------------------
`cli` (command-line application) | 10.8 MB | 21.7 MB
`gui` (JavaFX desktop application) | 29.1 MB | 45.8 MB
[electron-quick-start](https://github.com/electron/electron-quick-start) example | 32.8 MB | 131 MBHow to Build
------------
To run these Gradle commands, your system must have a `JAVA_HOME` environment variable pointing to a
Java 9+ location (the JDK subdirectory, not the JRE one).`gradlew linkAll`
To build the command-line version or the JavaFX version separately, use:
`gradlew cli:link`
`gradlew gui:link`
You can find the output under the `cli/build/dist` and/or `gui/build/dist` subdirectories.
Each bundle will have a `/bin` subdirectory, containing UNIX shell scripts or Windows batch files with
the same name as the subproject (e.g. `cli`, `gui.bat`).The contents of either `dist` subdirectory can be copied and run anywhere (assuming the same platform
type as the machine on which the bundle was made). You could also use any installer tool of your
choice to make a one-click installer artifact.