Displaying getRuntime().exec() Process CMD Window

Hello,

I'm using Runtime.exec() to run some Windows XP SP2 command line arguments from the command prompt, namely, an ftp client. The code looks something like:

Process p = Runtime.getRuntime().exec("cmd /c \"cd this && that.bat -script script.txt\"");

Now, this works, but I want the command prompt window to pop-up, so that the user can see the process running (it is a long process).

How can I achieve this?

[450 byte] By [bigOlogNa] at [2007-11-27 11:05:26]
# 1

TryProcess p = Runtime.getRuntime().exec("cmd /c start cmd /c \"cd this && that.bat -script script.txt\"");

dwga at 2007-7-29 13:08:41 > top of Java-index,Java Essentials,Java Programming...
# 2

Thanks,

That worked, very fast fix!

bigOlogNa at 2007-7-29 13:08:41 > top of Java-index,Java Essentials,Java Programming...
# 3

> Now, this works, but I want the command prompt window

> to pop-up, so that the user can see the process

> running (it is a long process).

>

> How can I achieve this?

It is easier to capture the process stdout and display it in a Frame or JFrame.

sabre150a at 2007-7-29 13:08:41 > top of Java-index,Java Essentials,Java Programming...
# 4

For that to work, I'll have to multithread right? Because the user must click a button to start the process. I'm just curious.

bigOlogNa at 2007-7-29 13:08:41 > top of Java-index,Java Essentials,Java Programming...
# 5

Yes, you would start a thread that reads from the output stream and appends to something like a JTextArea.

Note that JTextArea's append method is thread safe, i.e. you can call it right from the worker thread.

dwga at 2007-7-29 13:08:41 > top of Java-index,Java Essentials,Java Programming...
# 6

Thanks,

for this thread..

ravi-kumar-123a at 2007-7-29 13:08:41 > top of Java-index,Java Essentials,Java Programming...