- Lab
-
Libraries: If you want this lab, consider one of these libraries.
- Core Tech
Guided: Packaging a Java SE App with jlink and jpackage
Go beyond JAR files and learn to package your Java SE applications into lightweight, self-contained executables and native installers. This Code Lab guides you through using jlink to create a custom Java runtime and jpackage to build platform-specific installers, dramatically simplifying deployment and reducing the application’s footprint.
Lab Info
Table of Contents
-
Challenge
Introduction and Setup
Welcome! In this Code Lab, you'll master the art of packaging modern Java applications. You'll take a simple modular command-line tool and turn it into a professional, native installer.
The project is a Quote of the Day application, structured into two modules:
com.qotd.lib: A library module responsible for providing quotes.com.qotd.app: The main application module that consumes the library and displays the quote.
Your main task is to build a
build.shscript step-by-step. This script will automate the entire pipeline: compiling, running, packaging into JARs, creating a custom runtime withjlink, and finally, generating a native installer withjpackage. info> This lab experience was developed by the Pluralsight team using Forge, an internally developed AI tool utilizing Gemini technology. All sections were verified by human experts for accuracy prior to publication. For issue reporting, please contact us. -
Challenge
Implement and Compile the Modules
First, you'll get the application code working. Implement the core logic for the two modules and write the initial portion of your build script to compile them.
This step focuses on the fundamentals of the Java Platform Module System (JPMS) and using
javacto compile modular code. -
Challenge
Run and Package the Application
Now that you can compile the modules, the next steps are to run the application from the compiled classes and then package those classes into standard modular JAR files. This confirms that our module dependencies are correctly defined and prepares the code for distribution.
-
Challenge
Create a Custom Runtime with jlink
In this step, you’ll bundle a minimal Java runtime with your application so users do not need to install Java separately. The
jlinktool analyzes your application to determine which parts of the JDK are required and then creates a small, optimized runtime image. -
Challenge
Generate a Native Installer with jpackage
In this step, you’ll create a platform-native installer for the application. The
jpackagetool takes the application JAR files and the custom runtime image created withjlink, and bundles them into an installer such as a.debfile for Debian or Ubuntu, or an.msifile for Windows.
About the author
Real skill practice before real-world application
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.