在 Java 面板中包含命令提示符
I have a batch file that checks out code from SVN and calls few commands on it.This happens on the windows command prompt. I want to call this batch file from my java program and the command prompt must be present in the console of my application window and not as a separate window so I can see the output of the batch from my application.
Can anyone tell me how to include the command prompt to my console? I am using Swing.
解决方案If all you want is to see the output, forget the command prompt.
- Create a
ProcessBuilder
. - Call for the
Process
. - Read the output and error streams, and send them to something like
MessageConsole
.
BTW - When (not if) you run into problems using a Process
, see When Runtime.exec() won't & implement all the suggestions.
相关文章