External program execution in Java under windows Programme externe exécution en Java sous windows
Question? Amitava Ghosh wrote at caljug: Amitava Ghosh a écrit à caljug:
Dear all, Bonjour à tous,
I am trying to call an executable(written in C++) inside a java code through a Je suis en train de faire appel à un exécutable (écrit en C + +) dans un code java par le biais d'un
batch file(where the parameters for the C++ executable are stored). fichier batch (où les paramètres pour le C + + exécutable sont stockés).
When I am using Lorsque je me sers
Process p = Runtime.getRunTime().exec(”cppexe.bat”) Processus p = Runtime.getRunTime (). Exec ( "cppexe.bat")
it is working fine but when I am using start to run the batch process in a new window as in il fonctionne correctement mais lorsque je me sers commence à courir le lot dans une nouvelle fenêtre comme dans
Process p = Runtime.getRuntime().exec(”start cppexe.bat”) Processus p = Runtime.getRuntime (). Exec ( "start cppexe.bat")
I am getting an IOException Cannot create process etc etc Je reçois une IOException Impossible de créer un processus etc etc
Answer: start is a command of cmd.exe (under Windows NT/2000 etc.). Réponse: départ est une commande de cmd.exe (sous Windows NT/2000, etc.) So you should run it instead: Donc, vous devez l'exécuter au lieu:
Process p = Runtime.getRuntime().exec(”cmd /c start cppexe.bat”); Processus p = Runtime.getRuntime (). Exec ( "cmd / c début cppexe.bat");
Filed under Classé sous Java Software Logiciel de Java | |
| |
RSS 2.0 RSS 2,0 | |
Email this Article Envoyer cet article
You may also like to read Vous mai également à lire |





February 29th, 2004 at 10:04 pm Février 29th, 2004 chez 10:04 pm
Runtime.exec() is not a command line! Runtime.exec () n'est pas une ligne de commande!
You cannot do starts, redirections, etc. Vous ne pouvez pas ne commence, redirections, etc
Check this article: Cochez cette article:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
December 3rd, 2004 at 6:16 pm 3 décembre 2004 à 6:16 pm
You can invoke start if you prefix it with cmd.exe, essentially then cmd.exe is the command and the rest are parameters. Vous pouvez commencer à invoquer si vous préfixez-le avec cmd.exe, l'essentiel est alors cmd.exe la commande et le reste sont des paramètres. However why would you need to do start? Mais pourquoi auriez-vous besoin de faire commencer?
> To run the Windows command interpreter, execute either command.com or cmd.exe, depending on the Windows operating system you use. > Pour exécuter l'interpréteur de commandes Windows, exécutez l'une des command.com ou cmd.exe, selon le système d'exploitation Windows que vous utilisez. Listing 4.5 runs a copy of the Windows command interpreter and then executes the user-supplied command (eg, dir). L'annonce 4,5 gère une copie de l'interpréteur de commandes Windows, puis exécute l'utilisateur fourni par commande (par exemple, dir).
Yes, you can do re-directions using the same trick mentioned above. Oui, vous pouvez le faire re-directions en utilisant la même astuce mentionnée ci-dessus.
Actually the url you supplied gives the above solutions too. En fait l'url que vous avez fournies ci-dessus donne les solutions.
July 29th, 2007 at 11:00 am Juillet 29th, 2007 at 11:00 am
hey thank u very much Hey remercier et beaucoup
i was searching how to run cmd.exe in a java program je cherchais comment exécuter cmd.exe dans un programme Java
u helped me a lot et m'a beaucoup aidé
once again thank u very much remercier une fois de plus et beaucoup