Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use jpackage with WiX 4

Tags:

java

jpackage

I am trying to package an application with jpackage for Windows. I am using Java 19 and WiX 4.

Package Id      Version              Commands
---------------------------------------------
wix             4.0.0-preview.1      wix
java 19.0.1 2022-10-18
Java(TM) SE Runtime Environment (build 19.0.1+10-21)
Java HotSpot(TM) 64-Bit Server VM (build 19.0.1+10-21, mixed mode, sharing)

According to the Packaging Tool User's Guide, the requirements for generating an installation package for windows are:

WiX 3.0 or later is required.

However, when trying to generate a package I get an error:

[09:26:34.026] Can not find WiX tools (light.exe, candle.exe)
[09:26:34.026] Download WiX 3.0 or later from https://wixtoolset.org and add it to the PATH.

The very nature of the problem is clear. jpackage does not support WiX 4, although it is not written anywhere in plain text.

The solution is also clear, I install WiX 3. However, here comes the "problem". WiX 3 requires an old version of .Net (3.5.1) or at least "Windows features .Net 3.5.1". However, this is what I want to avoid.

My question is, as of today, is there a way to directly use WiX 4 with jpackage?

like image 500
mr mcwolf Avatar asked Dec 18 '25 14:12

mr mcwolf


2 Answers

WiX Toolset 4 and 5 Support

Support for WiX Toolset versions 4 and 5 was explicitly added in Java 24. See JDK-8319457 - Update jpackage to support WiX v4 and v5 on Windows.

From some testing, Java 24 also works with WiX Toolset 6. Not sure if this is explicitly supported though. And note that version 6 has seemingly added an open source maintenance fee for projects that generate revenue. See Introduce the Open Source Maintenance Fee #8974. I don't know if that applies to Java projects which indirectly use WiX Toolset 6 via jpackage, if Java itself has to cover the fee, or what this means regarding future support of WiX Toolset by jpackage.

Older versions of Java only support WiX Toolset 3. As I understand it, the command line tools of WiX Toolset were reorganized in version 4, and so jpackage can no longer find light.exe and candle.exe (if I'm not mistaken, those two tools no longer exist as separate executables).


Installing WiX Toolset 4/5/6 via .NET

Installing WiX Toolset 4 or 5 has a bit of an issue. If you just do:

dotnet tool install wix --global --version 5.0.2

Then trying to execute jpackage (Java 24) will result in an IOException. This exception says the wix.exe command exited with an error code of 144. With verbose output, you'll see more information:

[15:11:09.145] Output:
    wix.exe : error WIX0144: The extension 'WixToolset.Util.wixext' could not be found. Checked paths: WixToolset.Util.wixext
[15:11:09.145] Returned: 144

This seems to be an issue with the NuGet package? I'm not sure. Regardless, if you execute:

wix extension add --global WixToolset.Util.wixext/5.0.2

Then jpackage will work correctly.

To reiterate, to install WiX Toolset 5 you apparently need to execute the following two commands:

dotnet tool install wix --global --version 5.0.2
wix extension add --global WixToolset.Util.wixext/5.0.2

Where you replace 5.0.2 with the version you want to use (5.0.2 is the latest 5.x version as of April 27, 2025).

like image 118
Slaw Avatar answered Dec 21 '25 02:12

Slaw


Workaround using wix-3 (no need to mess with dotnet):

  1. Download wix311-binaries.zip from WiX Toolset v3 releases
  2. Unpack the archive into wix3 folder
  3. Add the wix3 folder to PATH environment variable
  4. Restart your terminal for the PATH setting to take effect
  5. Try jpackage again
like image 20
mariusm Avatar answered Dec 21 '25 04:12

mariusm



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!