Bonjour,
D'abord mille excuse pour cette question 100 fois posée, mais je tourne en rond depuis de nombreux jours !
Je lance un process qui lance un runtime.exec d'une commande DOS.
Je consomme la sortie dans un thread.
Puis je consomme les erreurs dans un autre thread.
Je fais un wait de mon process.
Puis je refais la même chose avec une autre commande DOS.

Sous Eclipse les 2 commandes s’exécutent (avec un point d'arrêt dans le debuger après le premier wait),
mais quand je crée un .jar de mon application et que j’exécute ce jar, alors seul la première commande DOS s’exécute.

Voici mon code :
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
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
	public String requette, requette2;
	public ResultSet resultset, resultset2;
	public Boolean resultat, resultat2;
	public Statement statement, statement2;
 
	public CreatotoVerifAller() {
 
		try {
			Runtime runtime = Runtime.getRuntime();
			String classpath = getClassPathVerif();
			String[] command = new String[]{
					"cmd.exe",
					"/C",
					getLecteur(),
					"&",
					"cd",
					getWorkingDirectoryVerif(),
					"start",
					"&",
					"java",
					"-cp",
					classpath,
					"com.mapforce.MappingConsole",
					"/Run",
					getNumeroRunEnCours()
			};
			String workingDirectory = getWorkingDirectoryVerif();
 
			final Process process = runtime.exec(command,null,new File(workingDirectory));
 
			new Thread() {
				public void run() {
					try {
						BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
						String line = "";
						try {
							while((line = reader.readLine()) != null) {
							}
						} finally {
							reader.close();
						}
					} catch(IOException ioe) {
						ioe.printStackTrace();
					}
				}
			}.start();
 
			new Thread() {
				public void run() {
					try {
						BufferedReader reader = new BufferedReader(new InputStreamReader(process.getErrorStream()));
						String line = "";
						try {
							while((line = reader.readLine()) != null) {
							}	
						} finally {
							reader.close();
						}
					} catch(IOException ioe) {
						ioe.printStackTrace();
					}
				}
			}.start();
 
			int wait = process.waitFor();
 
			requette = "select * from `tototemp`.`adressagessi_erreur_aller`";
			requette2 = "select * from `tototemp`.`assure_erreur_aller`";
 
			try {
				statement =con.createStatement();
				if (statement.execute(requette)){
					resultset=statement.getResultSet();
					resultset.last();
					if (resultset.getRow() != 0)	
						System.out.println("La verif echoue. il y a " + resultset.getRow() + " erreurs dans table: adressagessi_erreur_aller ");
					else {
						statement2 =con.createStatement();
						if (statement2.execute(requette2)){
							resultset2=statement2.getResultSet();
							resultset2.last();
 							if (resultset2.getRow() != 0)	
 								System.out.println("La verif echoue. il y a " + resultset2.getRow() + " erreurs dans table: assure_erreur_aller");
 							else {
 
							classpath = getClassPathAller();
							command= new String[]{
								"cmd.exe",
								"/C",
								getLecteur(),	
								"&",
								"cd",
								getWorkingDirectoryAller(),
								"start",
								"&",
								"java",
								"-cp",
								classpath,
								"com.mapforce.MappingConsole",
								"/Run",
								getNumeroRunEnCours()
							};
							workingDirectory  = getWorkingDirectoryAller();
							final Process process2 = runtime.exec(command,null,new File(workingDirectory));
 
							new Thread() {
								public void run() {
									try {
										BufferedReader reader = new BufferedReader(new InputStreamReader(process2.getInputStream()));
										String line = "";
										try {
											while((line = reader.readLine()) != null) {			
											}
										} finally {
											reader.close();
										}
									} catch(IOException ioe) {
										ioe.printStackTrace();
									}
								}
							}.start();
 
 
							new Thread() {
								public void run() {
									try {
										BufferedReader reader = new BufferedReader(new InputStreamReader(process2.getErrorStream()));
										String line = "";
										try {
											while((line = reader.readLine()) != null) {
											}
										} finally {
											reader.close();
										}
									} catch(IOException ioe) {
										ioe.printStackTrace();
									}
								}
							}.start();
 
							int wait2 = process2.waitFor();			
 							}	
						}
					}
				}
			}
			catch (Exception e1) {
				System.out.println("L'aller echoue.");
				e1.printStackTrace();
			}
		}
		catch (Exception e2) {
			System.out.println("La verif echoue");
			e2.printStackTrace();
		}
	}
Auriez-vous une piste pour m'aider ?