Bonjour!
J'ai un code qui fonctionne tres bien sous windows mais quand je veux l'executer sous linux, je prend une exception.
La fonction generant l'exception est une fonction permettant de lancer un exe externe...
Voici un bout de 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 private void callExec (String [] cmd, String env) { try { Runtime rt = Runtime.getRuntime() ; String temp = ""; for (int i = 0 ; i < cmd.length ; i++) { System.out.println("temp = " + cmd[i]); temp += cmd[i]; } System.out.println("Env = " + env); System.out.println("cmd = " + temp); Process proc = rt.exec(cmd, null, new File(env) ) ; java.io.InputStream stdin = proc.getInputStream () ; java.io.InputStream stderr = proc.getErrorStream(); InputStreamReader isr = new InputStreamReader (stdin) ; InputStreamReader isrerr = new InputStreamReader (stderr) ; BufferedReader br = new BufferedReader (isr) ; BufferedReader brerr = new BufferedReader (isrerr) ; String line = null ; while ( (line = br.readLine()) != null) System.out.println(line) ; while ( (line = brerr.readLine()) != null) System.out.println(line) ; // Mise en attente tant que le process n'est pas termine. int exitVal = proc.waitFor() ; if (exitVal != 0) { // Si la simulation s'est mal deroule, alors on fait remonter l'exception et on quitte throw new Exception ("\n \n Exit Process... \n \n") ; } } catch (IOException ioex) { System.out.println("Hapke process IOException exception"); System.out.println (ioex.getMessage ()) ; ioex.printStackTrace () ; System.exit(1) ; } catch (Exception ex) { System.out.println (ex.getMessage ()) ; ex.printStackTrace () ; System.exit(1) ; } }
Et apres lancement sous linux, j'obtiens ceci :
Pourtant, quand je lance a la main la chaine contenu dans "cmd" dans une console, tout marche sans probleme...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 temp = "/usr/dart/bin/hapke/hapke.exe" temp = "/home/vincent/DART/dart_local/simulations/testDART2/input/data.txt" temp = 1 Env = /usr/dart/bin/hapke cmd = "/usr/dart/bin/hapke/hapke.exe""/home/vincent/DART/dart_local/simulations/testDART2/input/data.txt"1 Hapke process IOException exception java.io.IOException: "/usr/dart/bin/hapke/hapke.exe": not found java.io.IOException: java.io.IOException: "/usr/dart/bin/hapke/hapke.exe": not found at java.lang.UNIXProcess.<init>(UNIXProcess.java:148) at java.lang.ProcessImpl.start(ProcessImpl.java:65) at java.lang.ProcessBuilder.start(ProcessBuilder.java:451) at java.lang.Runtime.exec(Runtime.java:591) at cesbio.dart.hapke.DartHapke.callExec(Unknown Source)
Quelqu'un a une explication?
Merci!
Partager