DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Jakarta NoSQL: Why JPA Is Not Enough for the AI Era
  • Top Java Security Vulnerabilities and How to Prevent Them in Modern Java
  • A Spring Boot App With Half the Startup Time
  • Implementing the Planning Pattern With Java Enterprise and LangChain4j

Trending

  • The Hidden Cost of AI-Generated Frontend Code
  • Operationalizing Enterprise AI at Scale: Architecture, Governance, and Adoption
  • Reducing RAG Hallucinations With Relationship-Aware Retrieval
  • Introducing RAI Audit Kit: Evidence-Grade Responsible AI Audits in Python
  1. DZone
  2. Coding
  3. Java
  4. Make Your Own MSI (and RPM, DEB, and DMG) with JDK14

Make Your Own MSI (and RPM, DEB, and DMG) with JDK14

This article demonstrates one of the new features of Java 14, the ability to create native installer versions of a complete JDK.

By 
Jim Connors user avatar
Jim Connors
·
Apr. 21, 20 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
6.1K Views

Join the DZone community and get the full member experience.

Join For Free

Throughout much of its long history, Java Runtime Environments for MS-Windows have traditionally been packaged up in the venerable EXE format for installation.  This made for a well understood, straightforward and standard way of installing Java for individual users, unfortunately at the expense of those tasked with managing Windows systems en masse.  EXE files don't necessarily play well in the Windows systems administration world where tools like Microsoft SCCM and many other capable alternatives are used.  A more preferable payload is the MSI format.  The equivalents in the Linux and macOS world would be the RPM/DEB and DMG formats respectively.

To help rectify this shortcoming, some organizations have seen fit to produce their own MSI versions. Oracle, for example, provides an Enterprise MSI Installer for its Java SE Subscription customers with its Oracle JDK 7 and JDK 8 releases. Among the litany of Open JDK distributions, a few have also decided to package up their own MSI versions too.

JDK 14 marks the introduction of a formal incubator module called  jdk.incubator.jpackage , addressing the ability to package up Java applications in native format. The full extent of the tool is far beyond the scope of this article; one of the corner cases that the jpackage tool handles is the ability to simply create native installer (MSI, DEB, RPM, DMG) versions of a complete JDK.

Examples

Let's cut to the chase and show examples on two of the three major platforms.  For Windows, we'll use an Oracle JDK 14 instance located in the  D:\jdk-14  directory.  The following command will create a JDK 14 MSI file where the name and vendor has been specified via the  -n  and  --vendor  arguments:

Java
 




x


 
1
D:\>  jdk-14\bin\jpackage -n jdk-14-GA --type msi --vendor "Joe Schmo" --runtime-image jdk-14


There are additional directives that can be furnished to further customize the resulting package. Upon completion of the  jpackage  command, a file named  jdk-14-GA-1.0.msi  is created.  Once installed it appears in the Windows registry as follows:

File in the Windows registry

File in the Windows registry


In the Linux world, we'll use Oracle's OpenJDK 14 distribution. Two sample invocations follow, one to create a DEB package, the other to create an RPM:

Shell
 




xxxxxxxxxx
1


 
1
$ jdk-14/bin/jpackage -n openjdk-14-GA --type deb --vendor "Joe Debian" --runtime-image jdk-14


produces a file named  openjdk-14-ga_1.0-1_amd64.deb 

Shell
 




xxxxxxxxxx
1


 
1
$ jdk-14/bin/jpackage -n openjdk-14-GA --type rpm --vendor "Joe RedHat" --runtime-image jdk-14


produces a file named  openjdk-14-ga_1.0-1.x86_64.rpm 

On a Ubuntu system, the openjdk-14-ga_1.0-1_amd64.deb file can be installed and verified as shown by the screenshot that follows:

Verification of file

Verification of file


Conclusion

Two points are worth mentioning:

  • There is no notion of cross-building packages. That is to say, you must run jpackage on the same platform you wish to create a package for. Create Windows packages on Windows systems, Linux packages on Linux systems and MacOS packages on MacOS systems.
  • The Java Packaging Tool is in the incubator stage.  Incubator modules put technology in the hands of developers prior to finalization.  As such, expect further refinements to the jpackage  API as community feedback is solicited.
Deb (file format) Java (programming language)

Opinions expressed by DZone contributors are their own.

Related

  • Jakarta NoSQL: Why JPA Is Not Enough for the AI Era
  • Top Java Security Vulnerabilities and How to Prevent Them in Modern Java
  • A Spring Boot App With Half the Startup Time
  • Implementing the Planning Pattern With Java Enterprise and LangChain4j

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook