Home > Mobile >  How to create launcher as windows service using jpackage (Java 19)
How to create launcher as windows service using jpackage (Java 19)

Time:10-08

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?

CodePudding user response:

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
  • Related