Bonjour,

Je suis confronté à un petit problème, auquel Google n'a pas encore pu répondre (ou alors je cherche mal, ce qui n'est pas impossible ^^)

J'ai besoin de lancer un programme Java depuis mon Code VB.NET.
Jusque là rien de très compliqué, je fais appel au petit bout de code suivant :

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
 
Dim myProcess As New Process
myProcess.StartInfo.FileName = JDKPath + "\bin\java.exe"
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
myProcess.StartInfo.CreateNoWindow = True
myProcess.StartInfo.UseShellExecute = False
myProcess.StartInfo.RedirectStandardError = True
myProcess.StartInfo.Arguments = currentFolder + "\myProgram.jar"
myProcess.Start()
 
'Read the standard error of myProgram.jar
Dim myStreamReader As StreamReader = myProcess.StandardError
Dim errorMsg = myStreamReader.ReadToEnd()
 
myProcess.WaitForExit()
myProcess.Close()
Quand j'ai une erreur retournée par le programme Java, j'en suis averti grâce à la commande
StandardError
Problème :

Or, côté Java mon programme peut renvoyer plusieurs type d'erreur en fonction de son code de sortie :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
 
// Erreur critique
System.exit(1);
 
// Erreur benigne
System.exit(-1);
 
// Pas d'erreur
System.exit(0);
J'aurais donc besoin d'aide pour savoir comment récupérer et identifier le retour du jar que j'ai lancé en B]VB.NET[/B] ?

Par avance merci