<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>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.</p>
<p>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(...)).</p>
<p>In theory it should work, but why the f*** is it so complicated
and so poorly documented?<br>
</p>
<p>[1]
<a class="moz-txt-link-freetext" href="https://stackoverflow.com/questions/73951976/how-to-create-launcher-as-windows-service-using-jpackage-java-19">https://stackoverflow.com/questions/73951976/how-to-create-launcher-as-windows-service-using-jpackage-java-19</a><br>
[2]
<a class="moz-txt-link-freetext" href="https://github.com/openjdk/jdk/pull/7793/files#diff-a2550383f6504a1a738fafccff8e452d080891ad992fd36798683a4ce17c5707">https://github.com/openjdk/jdk/pull/7793/files#diff-a2550383f6504a1a738fafccff8e452d080891ad992fd36798683a4ce17c5707</a><br>
</p>
<div class="moz-cite-prefix">On 21.10.22 22:16, Alexey Semenyuk
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:4d662248-f9ab-aa67-027c-044a21cd8c98@oracle.com">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<div class="moz-text-html" lang="x-unicode"> Hi Tobias,<br>
<br>
OS-specific means are used to manage services. You can find
details in <a class="moz-txt-link-freetext"
href="https://bugs.openjdk.org/browse/JDK-8275062"
moz-do-not-send="true">https://bugs.openjdk.org/browse/JDK-8275062</a>
CSR<br>
<br>
- Alexey<br>
<br>
<div class="moz-cite-prefix">On 10/21/2022 2:51 PM, Tobias
Oelgarte wrote:<br>
</div>
<blockquote type="cite"
cite="mid:71d534b6-e387-0ea0-78ae-6a2d5d86941b@gmail.com">
<p>I read the documentation for jpackage and found the <a
id="option-launcher-as-service" moz-do-not-send="true"><code>--launcher-as-service
</code></a>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.<br>
</p>
<p>How is this supposed to work? From my understanding each
service provides a mechanism to be started and stopped. <br>
</p>
<p>I assume that the starting mechanism is the typical
main(...) method and not some implementation of a "Service"
interface. <br>
</p>
<p>But how does the stopping work and how is a service
supposed to do an orderly shutdown?<br>
</p>
</blockquote>
<br>
</div>
</blockquote>
</body>
</html>