Create a windows service from my java app

198 views
Skip to first unread message

Davide Perini

unread,
Oct 23, 2020, 11:30:45 AM10/23/20
to jna-...@googlegroups.com
Hi guys,
using JPackage to create my MyRunnableBinary.exe

is there a way to make "MyRunnableBinary.exe" start with Windows?
Should I create a service to make it start with Windows?

If yes, is there a way in JNA to create a windows service for the purpose?

Thanks
Davide

Tres Finocchiaro

unread,
Oct 23, 2020, 12:08:33 PM10/23/20
to jna-...@googlegroups.com
My reply is slightly off-topic, but here's a small wiki for turning a Java application into a service using the NSSM service manager: https://github.com/qzind/tray/wiki/windows-service

Note, this tutorial is specific to a project I maintain, but the steps can be adapted.  The steps about %APPDATA% can be skipped, they're specific to the app and won't necessarily apply.

In regards to JNA's ability to create a Windows service, you could reverse engineer NSSM's source code or use one of the existing examples out there.

Finally, if your requirement is for the Java application to start on Login (not necessarily with the computer), then you can do this with a combination of standard Windows calls, such as using mslinks to write a windows desktop shortcut (.lnk) to the startup folder.  Note, there are user-startup folders, common startup folders and you may need elevated security to write to the common location.




--
You received this message because you are subscribed to the Google Groups "Java Native Access" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jna-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jna-users/0c8b6412-90b2-f148-da4c-4a5b0d3caed0%40dpsoftware.org.
Reply all
Reply to author
Forward
0 new messages