help required in using getRuntime.exec() and JFrames


R

Rohit Gupta

Hi,

I am using getRuntime.exec() in Jframes, and running another another
java file by the exec() functions, the java file produces another file
after running. Now I need to display the output of this file on the
JFrame, but the output file contains null value until and unless I exit
the Frame, after which the output file contains the required text. I
tried repaint(), but that didn't work, what should I do?

TIA

Rohit Gupta
 
Ad

Advertisements

M

Matt Humphrey

Rohit Gupta said:
Hi,

I am using getRuntime.exec() in Jframes, and running another another
java file by the exec() functions, the java file produces another file
after running. Now I need to display the output of this file on the
JFrame, but the output file contains null value until and unless I exit
the Frame, after which the output file contains the required text. I
tried repaint(), but that didn't work, what should I do?

It seems unusual that the exec does not finish until your Frame exits. It
suggests to me that you're either not giving the exec enough time to do its
job, or it's blocked waiting for your program to do something. As part of
running an exec, you need to simultaneously read standard out / standard
error from the program or it will block. If you show your exec code someone
may be able to determine if it's correct.

Cheers,
Matt Humphrey (e-mail address removed) http://www.iviz.com/
 
Ad

Advertisements

R

Rohit Gupta

Thanks, got the culprit......it was getting blocked....
Using this it worked...
Process p = Runtime.getRuntime().exec(command);
p.getInputStream().close();

Rohit
 

Top