I made a client server program that can send files from my android device to my windows 7, the server side program (windows) listens on a loop and reacts to the reception of sockets.
So I exported my java program to jar file and I executed the following command (after opening cmd as administrator) to make it a service:
prunsrv //IS//Colisage --DisplayName="Colisage" --Description="Colisage" --Install="C:\Pda\prunsrv.exe" --Jvm="C:\Program Files\Java\jdk1.8.0_161\jre\bin\server\jvm.dll" --StartMode=jvm --StopMode=jvm --Startup=auto* --Classpath="C:\Pda\colisage.jar" --LogLevel=DEBUG^ --LogPath="%cd%\logs" --LogPrefix=procrun.log --StdOutput="%cd%\logs\stdout.log" --StdError="%cd%\logs\stderr.log"
the service was created and executed correctly.
This is what the procrun.log file displays:
[2018-06-07 16:04:12] [debug] ( prunsrv.c:1729) [ 3708] Commons Daemon procrun log initialized
[2018-06-07 16:04:12] [info] ( prunsrv.c:1733) [ 3708] Commons Daemon procrun (1.1.0.0 64-bit) started
[2018-06-07 16:04:12] [debug] ( prunsrv.c:602 ) [ 3708] Installing service...
[2018-06-07 16:04:12] [info] ( prunsrv.c:641 ) [ 3708] Service Colisage name Colisage
[2018-06-07 16:04:12] [debug] ( prunsrv.c:657 ) [ 3708] Setting service description Colisage
[2018-06-07 16:04:12] [info] ( prunsrv.c:675 ) [ 3708] Service 'Colisage' installed
[2018-06-07 16:04:12] [info] ( prunsrv.c:1814) [ 3708] Commons Daemon procrun finished
[2018-06-07 16:04:53] [debug] ( prunsrv.c:1729) [ 2116] Commons Daemon procrun log initialized
[2018-06-07 16:04:53] [info] ( prunsrv.c:1733) [ 2116] Commons Daemon procrun (1.1.0.0 64-bit) started
[2018-06-07 16:04:53] [info] ( prunsrv.c:1643) [ 2116] Running 'Colisage' Service...
[2018-06-07 16:04:53] [debug] ( prunsrv.c:1417) [ 1120] Inside ServiceMain...
[2018-06-07 16:04:53] [debug] ( prunsrv.c:885 ) [ 1120] reportServiceStatusE: dwCurrentState = 2, dwWin32ExitCode = 0, dwWaitHint = 3000, dwServiceSpecificExitCode = 0
[2018-06-07 16:04:53] [info] ( prunsrv.c:1175) [ 1120] Starting service...
[2018-06-07 16:04:53] [debug] ( javajni.c:236 ) [ 1120] loading jvm 'C:\Program Files\Java\jdk1.8.0_161\jre\bin\server\jvm.dll'
[2018-06-07 16:04:53] [debug] ( javajni.c:753 ) [ 4208] Jvm Option[0] -Djava.class.path=C:\Pda\colisage.jar
[2018-06-07 16:04:53] [debug] ( javajni.c:753 ) [ 4208] Jvm Option[1] exit
[2018-06-07 16:04:53] [debug] ( javajni.c:753 ) [ 4208] Jvm Option[2] abort
[2018-06-07 16:04:53] [debug] ( javajni.c:990 ) [ 4208] Java Worker thread started Main:main
[2018-06-07 16:04:54] [debug] ( prunsrv.c:1235) [ 1120] Java started Main
[2018-06-07 16:04:54] [info] ( prunsrv.c:1333) [ 1120] Service started in 1284 ms.
[2018-06-07 16:04:54] [debug] ( prunsrv.c:885 ) [ 1120] reportServiceStatusE: dwCurrentState = 4, dwWin32ExitCode = 0, dwWaitHint = 0, dwServiceSpecificExitCode = 0
[2018-06-07 16:04:54] [debug] ( prunsrv.c:1572) [ 1120] Waiting for worker to finish...
stdout.log file:
connection attempt ..
successfully connected
waiting on port 11845 ...
What corresponds to what is supposed to display my program at the beginning, here is the portion of the java program that interests us:
System.out.println ("waiting on port" + String.valueOf (port) + "...");
clientSocket = serverSocket.accept ();
System.out.println ("Receiving the request");
to summarize, when I run my java program either on eclipse or jar, it runs fully and correctly receives the files while my service is only executing the beginning, it does not receive sockets.
thank you in advance for your help