I am trying to open a new command prompt at my screen from my java program...
I have been able to do it but now i want to write in that new command prompt from the same java program...
IS IT POSSIBLE???
Don't know. Please show us how you did that (even though that may be Windows®-specific code which is contrary to the philosophy of platform-independence). Then we can see whether your code can be extended to write to the other command prompt.
Even when using ProcessBuilder you must still empty both Streams from the Process. I suspect that code will block because you are reading the whole of the error stream before you finish the output stream. Google for When Runtime.exec() won't Michael Daconta; the article might be old, but it is still relevant.
Adam Outler wrote:Runtime has problems. use ProcessBuilder
Any problems are likely of your making since when ProcessBuilder was introduced (JDK 1.5 ?) Runtime.exec() was re-engineered so as to use ProcessBuilder behind the scenes. In general, I find ProcessBuilder has a couple of features that make it easier to use than Runtime.exec().
Getting back to the OP's original problem. I have been thinking about this for some time I'm not convinced one can do what the OP wants. One can write to the cmd.exe Process stdin but this is interpreted by cmd.exe and not just echoed to the output window. In the article I am writing on Runtime.exec() and ProcessBuilder I bypass the problem and just write the output to a JTextArea.
Retired horse trader.
Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.