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
 
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/
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top