I created a Windows Service from a .jar from NSSM using a batch file. I exported my code from eclipse as a jar file. With Library handling: Extract required libraries into generated jar.
The program uses java's WatchService to check if a file is created in a folder. It also uses Apache PDFBox API to modify the PDF that was created in the folder.
I was able to make the jar file to run as Window's service but does not modify the PDF. The jar file alone runs correctly but when it is a service it does nothing.
This is how I created the service:
pushd "<path to jar>"
nssm.exe install "<service Name>" "C:\Program Files\Java\jre1.8.0_211\bin\java.exe" -jar <jar name>
nssm.exe set "<service Name>" AppDirectory "<path to jar>"
The program is expected to open the PDF and add text fields to the top the PDF. The actual results is that the service does nothing.
Update: The reason why the Window Service is not displaying the JOptionPane is because the service runs in the background not allowing the JOptionPane to show up.
Allow service to interact with desktop
The selection above does not allow the JOptionPane to show up.