jpackage and launcher-as-service parameter

Tobias Oelgarte tobias.oelgarte at gmail.com
Fri Oct 21 20:47:51 UTC 2022


After some digging, i come to the conclusion, that i would need to put 
nssm.exe (renamed to service-installer.exe [1]) into the resource 
directory, to make it work with the default "service-install.wxi" and 
"service-install.wxi" provided by jpackage (both target nssm [2]). If i 
would use some other "service manager" i would need to override both 
files with custom replacements for that service manager to work.

Nssm, when stopping a service, sends an "interrupt" to JVM which forces 
it to shutdown. The only way to react to the shutdown is a shutdown hook 
(Runtime.getRuntime().addShutdownHook(...)).

In theory it should work, but why the f*** is it so complicated and so 
poorly documented?

[1] 
https://stackoverflow.com/questions/73951976/how-to-create-launcher-as-windows-service-using-jpackage-java-19
[2] 
https://github.com/openjdk/jdk/pull/7793/files#diff-a2550383f6504a1a738fafccff8e452d080891ad992fd36798683a4ce17c5707

On 21.10.22 22:16, Alexey Semenyuk wrote:
> Hi Tobias,
>
> OS-specific means are used to manage services. You can find details in 
> https://bugs.openjdk.org/browse/JDK-8275062 CSR
>
> - Alexey
>
> On 10/21/2022 2:51 PM, Tobias Oelgarte wrote:
>>
>> I read the documentation for jpackage and found the 
>> |--launcher-as-service |option. The documentation states: "Request to 
>> create an installer that will register the main application launcher 
>> as a background service-type application." But that is everything i 
>> could find.
>>
>> How is this supposed to work? From my understanding each service 
>> provides a mechanism to be started and stopped.
>>
>> I assume that the starting mechanism is the typical main(...) method 
>> and not some implementation of a "Service" interface.
>>
>> But how does the stopping work and how is a service supposed to do an 
>> orderly shutdown?
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/jdk-dev/attachments/20221021/fd1fec32/attachment.htm>


More information about the jdk-dev mailing list