Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

running an executable from prgm

Status
Not open for further replies.

tictaclam

Programmer
Jan 8, 2004
47
US
Hi, I'm trying to run an executable from my program. I can get the executable to run, but I don't know how to get the information from the executable into a file. If you run an executable from the command windown you can type:
C:\myExecutable.exe args > info.txt

and all the information that would be printed on the screen goes into the file. Is there anyway to do this when you run it from java code? my code is the following:

Runtime r = java.lang.Runtime.getRuntime();
Process p = r.exec(path + myExecutable.exe + " > info.txt");

this doesn't work any ideas how I can do it?
thanks
~tictac~
 
Hi
I realized that i could use the getOutputStream() method in the Process class. but once i get the outputStream from the subprocess how can i read the information in the outputStream?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top