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

Document how a CLI app can be packaged for distribution #814

Closed
remkop opened this issue Sep 17, 2019 · 0 comments
Closed

Document how a CLI app can be packaged for distribution #814

remkop opened this issue Sep 17, 2019 · 0 comments
Milestone

Comments

@remkop
Copy link
Owner

remkop commented Sep 17, 2019

== Packaging Your Application

Subsections below discuss some options you have for packaging your application for distribution.

=== Build Tool Plugins

Both https://www.mojohaus.org/appassembler/[Application Assembler Maven Plugin] and https://docs.gradle.org/current/userguide/application_plugin.html[Gradle Application plugin] create a distribution zip or tar file with launcher scripts. Both require a JRE to be installed on the target machine.

=== Launch4j and JDK 8 JavaPackage
http://launch4j.sourceforge.net/docs.html[launch4j] and JDK 8 https://docs.oracle.com/javase/8/docs/technotes/tools/windows/javapackager.html[javapackage] can create a native launcher executable. Can bundle a JRE (~200MB) or use a pre-installed one.

=== JLink
Java 9 introduced the JPMS module system and it is now possible to use https://docs.oracle.com/javase/9/tools/jlink.htm#JSWOR-GUID-CECAC52B-CFEE-46CB-8166-F17A8E9280E9[jlink] to create a custom light-weight JRE with only the necessary modules. JLink also generates launcher scripts. (JLink can be https://medium.com/azulsystems/using-jlink-to-build-java-runtimes-for-non-modular-applications-9568c5e70ef4[used] for non-modular apps.)

=== JPackage (Early Access)
https://jdk.java.net/jpackage/[jpackage] (early access build) https://openjdk.java.net/jeps/343[JEP 343: Packaging Tool]. JPackage can take the custom light-weight JRE produced by JLink and create an installer and a native application launcher. The result is not a single executable but a Java "application image" that is a single directory in the filesystem containing the native application launcher, resources and configuration files, and the custom light-weight JRE runtime image (including the application modules) produced by JLink. See also https://www.infoq.com/news/2019/03/jep-343-jpackage/[this InfoQ article]. Gradle users may like these plugins: https://badass-runtime-plugin.beryx.org/releases/latest/[org.beryx Badass Runtime Plugin] and https://badass-jlink-plugin.beryx.org/releases/latest/[org.beryx Badass JLink Plugin].

=== GraalVM Native Image
https://www.graalvm.org/docs/reference-manual/aot-compilation/[GraalVM native-image] allows you to ahead-of-time compile Java code to a standalone executable, called a native image. This executable includes the application, the libraries, the JDK and does not run on the Java VM, but includes necessary components like memory management and thread scheduling from a different virtual machine, called “Substrate VM”. Substrate VM is the name for the runtime components (like the deoptimizer, garbage collector, thread scheduling etc.). The resulting program has faster startup time and lower runtime memory overhead compared to a Java VM.

// * https://en.wikipedia.org/wiki/Service_wrapper[service wrapper]? Wrapper program to run your Java program as a Windows Service or Unix Daemon. Not discussed in more detail in this article.

https://steveperkins.com/using-java-9-modularization-to-ship-zero-dependency-native-apps/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant