4

I want to create an installer with jpackage that registers my java application launcher as a Windows service.

I have installed WiX Toolset v3.11.2.

I have tried to create my installer by specifying the --launcher-as-service flag which is supported in Java 19 JDK-8275062 but I am getting the following error:

> jpackage --type msi -i . --main-jar my-app.jar --name my-app --app-version "1.0.00" --dest . --win-shortcut --win-menu --launcher-as-service
Bundler MSI Installer Package failed because of java.lang.NullPointerException: Cannot invoke "jdk.jpackage.internal.InstallableFile.srcPath()" because "this.serviceInstaller" is null

The documentation mentions a certain service installer executable (service-installer.exe) as a resource to consider. Any idea where I can find this executable and what would be the best thing to do?

NassimBtk
  • 71
  • 5

1 Answers1

3

I've been able to manage this issue by configuring the --resource-dir option to specify the NSSM resource path, and I have renamed nssm.exe to service-installer.exe.

> jpackage --type msi -i . --main-jar my-app.jar --name my-app --app-version "1.0.00" --dest . --win-shortcut --win-menu --resource-dir "C:\Program Files\nssm-2.24\win64" --launcher-as-service
NassimBtk
  • 71
  • 5
  • Yes, `jpackage` has been designed to work with NSSM: https://github.com/openjdk/jdk/blob/master/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/service-config.wxi#L6 . If you want to use another service wrapper such as WinSW, you will need to override `service-config.wxi` and `service-install.wxi` – Morgan Courbet Mar 17 '23 at 08:29
  • please give me more details about this answer because the installer refers to `service_installer.exe` as a service, not my application `exe` – Ahmed Saber Jul 12 '23 at 07:27