Bonjour à tous, j'ai fait un programme serveur client qui permet d'envoyer des fichiers depuis mon appareil android vers mon mon pc windows 7, le programme coté serveur (windows) écoute en boucle sur un port et réagit à la réception de sockets.
J'ai donc exporter mon java en fichier jar et j'ai executé la commande suivante (après avoir ouvert le terminal en tant qu'administrateur) pour en faire un service:
le service a été créé et s'est exécuté correctement.
Code : Sélectionner tout - Visualiser dans une fenêtre à part 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"
Voici ce qu'affiche le fichier procrun.log :
quant au fichier stdout.log :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 [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...
Ce qui correspond à ce qu'est censé afficher mon programme au début, voici la portion du programme java qui nous intéresse:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 tentative de connexion.. connecté avec succès En attente sur le port 11845 ...
Enfin bref, pour résumer, lorsque j’exécute mon programme java que ce soit sous éclipse ou le jar, il s’exécute entièrement et reçoit correctement les fichiers tandis que mon service lui n’exécute que le début, il ne reçoit pas de sockets.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 System.out.println("En attente sur le port " + String.valueOf(port) + " ..."); clientSocket = serverSocket.accept(); System.out.println("Réception de la requete");
Merci d'avance pour votre aide
Partager