JEP Package Tool in Java

JEPs, or Java Enhancement Proposals, are ideas for enhancing the Java platform. The JEP Package Tool is one such improvement that enables programmers to package Java programs as native executables.

The creation of native executables from Java programs is possible through the implementation of the JEP Package Tool by developers. Doing so grants independence to these executable files that eliminate dependency on a Java Virtual Machine (JVM) or other associated software components. The advent of this powerful tool began in Java 14 through its introduction as an experimental feature.

Syntax for Using JEP Package Tool

The JEP Package Tool's syntax is simple to read and comprehend. To utilize the JEP Package Tool. It is imperative that JDK 14 is installed on your machine. As the tool works through the command line. Opening a terminal window or command prompt is necessary for its use. Here is the JEP Package Tool's syntax −

jpackage [options]

The [options] field gives the various parameters you may use to modify the JEP Package Tool's behavior. Optional and compulsory choices can be separated into two groups.

The options are −

  • --name <name> − The name of the package.

  • --input <directory> − The input directory containing the application files.

  • --main-jar <jar-file> − The name of the main JAR file.

  • --main-class <class-name> − The name of the main class.

  • --type <type> − The type of the package (e.g., exe, msi, deb, rpm).

  • --output <file> − The name of the output file.

  • --vendor <name> − The name of the vendor.

  • --copyright <copyright> − The copyright notice.

  • --description <description> − The description.

  • --resource-dir <directory> − The directory containing the resources.

How to Use JEP Package Tool

Follow these steps to utilize the JEP Package Tool −

  • Step 1 − Install Java 14 or later

    The sole requirement for using the JEP Package Tool is having Java 14 or a newer iteration on board. Therefore, in case your device lacks this version of Java software already installed; installing it is mandatory for accessing the tool.

  • Step 2 − Create a Java application

    In order to package a Java application as a native executable, create it. A non-modular application or a modular application can be used.

  • Step 3 − Compile the application

    Utilize the Java compiler to compile the program

  • Step 4 − Create the package

    The JEP Package Tool may be used to produce the native executable package once the program has been built. To accomplish this, you must supply the module's name and the location of the output file.

    Here is an example command for the JEP Package Tool to produce a native executable package −

jpackage --name MyApplication --input target/modules --main-jar MyApp.jar --main-class com.example.MyApp --type exe --output MyApplication.exe

With regards to this particular example, the software being employed carries the name of "MyApplication", and operates via a central JAR file aptly titled "MyApp.jar". Access to data input can be found in the designated directory labeled as "target/modules". Additionally, the leading class integral to this program's operation goes by the name of "com.example.MyApp". The resulting product generated from utilizing such processes will deposit pertinent information within an output file labeled as "MyApplication.exe", designed within the bounds of a package structure specified as an executable ("exe") format.

Different Approaches of Using Attributes in Servlets

There are several methods based on the particular requirements of your application, to use the JEP Package Tool.

Approach 1: Packaging One JAR File Only

In case your program is made up of just one JAR file look no further than the JEP Package Tool that allows you to generate a self-sufficient executable file. Notably. This executable operates without necessitating a distinct JRE installation on any computer. For instance −

jpackage --input /path/to/myapp.jar --main-jar myapp.jar

Generating an autonomous executable file is feasible with this command. It will result in a file titled myapp that can be performed on any computer effortlessly.

Approach 2: Packaging a Directory With Several Files

Developers grappling with several distributed resource and configuration files or distinct libraries should go for the JEP Package Tool which offers an efficient solution. With this tool at hand, one can produce an all-inclusive executable package with all required content therein.

jpackage --input /path/to/myapp --main-jar myapp.jar

The command will create a self contained executable file, called myapp that includes all files within the /path/to/myapp directory.

Approach 3: Generating Executable Files For Several Platforms

To create platform-specific executable files like EXE files for Windows or DMG files for macOS, JEP Package Tool's --type option can be utilized. Here are some command examples −

jpackage --input /path/to/myapp --main-jar myapp.jar --type exe

This particular command has the capability to generate Myapp.exe - an entirely self contained and highly adaptable executable file that was specifically created for use in Windows environments.

jpackage --input /path/to/myapp --main-jar myapp.jar --type dmg

Myapp.dmg, a self-contained executable file that can be executed on macOS, will be produced by this command.

Advanced Features of JEP Package Tool

Additionally, the JEP Package Tool offers a number of sophisticated features that can be used to further tailor the package. Here are a few illustrations −

Creating a Customized Splash Screen

To provide a unique splash screen for your program, use the --splash option. A command example is as follows −

jpackage --input /path/to/myapp --main-jar myapp.jar --splash splash.png

A self-contained executable file with a unique splash screen called splash.png will be produced by this command.

Signing The Package

To sign the package using a certificate, use the --sign option. A command example is as follows −

jpackage --input /path/to/myapp --main-jar myapp.jar --sign mycert

This program will produce a self-contained executable file that is signed and has a certificate, named mycert, called myapp.

Incorporating JVM Choices

When launching the program, you may include JVM parameters by using the --java-options option. A command example is as follows −

jpackage --input /path/to/myapp --main-jar myapp.jar --java-options "-Xmx512m -Dmyprop=value"

The JVM options -Xmx512m and -Dmyprop=value will be included in the self-contained executable file that is produced by this command.


A strong tool that makes it simple for developers to package their Java programs into standalone executables is the JEP Package Tool. The JEP Package Tool may be used to produce executable files that are particular to a certain platform, customize the package with a unique splash screen and signature, and add JVM parameters to the application's runtime thanks to its straightforward syntax and sophisticated functionality. Developers may make Java applications more usable and accessible without requiring a separate JRE to be installed by utilizing the JEP Package Tool.

Updated on: 01-Aug-2023


Kickstart Your Career

Get certified by completing the course

Get Started