Question on executing an external program from Java code....

I want to execute a executable program on Windows which will take arguments and return back some parameters.

I know I need to

Runtime r = Runtime.getRuntime();
Process p = r.exec("myprogram.exe");

Should I parse all three of these?

pErrorStream = p.getErrorStream();  //for errors?
pInputStream = p.getInputStream();  //for input and program output?
pOutputStream = p.getOutputStream();  // for additonal input ?

So just to clarify for me if I want to send arguments send them to inputstream and look there too for the program you are excuting output's too?  Then OutputStream is only used to send additional input right?


thanks
ryno71
ryno71Asked:
Who is Participating?
 
CEHJConnect With a Mentor Commented:
Yes, you need to read the Process' streams on separate threads.

>>Then OutputStream is only used to send additional input right?

Yes
0
 
Mayank SConnect With a Mentor Associate Director - Product EngineeringCommented:
>> //for input and program output?

Only for reading the program output.
0
 
CEHJCommented:
:-)
0
All Courses

From novice to tech pro — start learning today.