logo

Packaging Tool


Show

Java 14 introduces a brand new packaging device, jpackage primarily based totally on javapackager. javapackager will be delivered in Java 8 and become a part of the JavaFX kit. As JavaFX is cut up from Java from 11 version, this packaging device is no extra to be had in preferred offerings.

This new device is advanced to offer a local installer for a running system. Like, an msi/exe for windows, pkg/dmg for MacOS, deb/rpm for Linux, and so on. Without this device, developers usually proportion a jar record which a consumer has to run inside a personal JVM.

Developers can use jlink to compress the specified JDK modules to minimal modules and use the jpackage to create a lightweight image.

Example

Examine the below given example:

APITester.java

public class APITester {
   public static void main(String[] args) {
      System.out.println("Welcome to TutorialsPoint.");
   }
}

Compile and Run The Program

$javac APITester.java

$jar cf APITester.jar APITester.class

Output

For Windows practicable, you have to download WiX Toolset v3.11.2(wix311-binaries.zip) and also add the toolkit to your path. Once Jar is made and the path is set, now put the jar in the folder called lib and run the following command to produce a windows MSI installer

$jpackage --input lib --name APITester --main-jar APITester.jar --main-class APITester --type msi --java-options '--enable-preview'

WARNING: Using incubator modules: jdk.incubator.jpackage