Bonjour
je veux executer une commande DOS sous java (je travaille sous windows avec eclipse 3.3)
voici ce que j'ai ecrit :
Sous l'invite de commande ça marche, mais ce code ne marche pas il me dit que le fichier spécifié est introuvalbe
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 try{ String[] cmd = new String[3]; cmd[0] = "cmd.exe" ; cmd[1] = "/C" ; cmd[2]="cd C:\\Program Files\\glassfish-v2.1\\bin"; Runtime rt = Runtime.getRuntime(); System.out.println("Execing " + cmd[0] + " " + cmd[1] + " " + cmd[2]); Process proc = rt.exec(cmd); }catch (Throwable t) { t.printStackTrace(); }
comment on spécifie le chemin d'accés ?
Partager