aspose file tools*
The moose likes Java in General and the fly likes capturing windows app's output Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "capturing windows app Watch "capturing windows app New topic
Author

capturing windows app's output

Servin Park
Greenhorn

Joined: May 10, 2002
Posts: 26
Hello,
I have a command prompt windows application (DOS like, call it "the-app" from this point on) that is not intuitive to use. So I built a java app that offers GUI screen to take user input and in the background converts information to proper commands that the-app undersands. And then using JNI, sends those commands to the-app. So far so good, my java app works and the-app responds without any problem. My problem is though, somehow I have to retrieve a couple reponses from the-app. In other words, at the end of process the-app prints confirmation number on its screen and I need to copy the confirmation number and paste it to my java app. Does anyone has any idea how I could do this? Or is it possible at all? Thanks in advance for your help.
Omar IRAQI
Ranch Hand

Joined: Jul 06, 2001
Posts: 54
Hi Servin,
I assume that you are using java.lang.Runtime.exec() to run "the_app". If this is actually the case, you can do the following :
Process the_appProcess = thisRuntime.exec("pathTothe_app + parameters");
InputStream ins = the_appProcess.getInputStream();
Once you have the ins handle, you can parse the stream and retrieve the needed data.
I Hope this would help.


Omar IRAQI Houssaini
Servin Park
Greenhorn

Joined: May 10, 2002
Posts: 26
Omar,
Thank you so much for your pointer. I would never have found Process class on my own. By the way, I noticed Process.getOutputStream() method. Does it mean my java app can even write to the-app?
Omar IRAQI
Ranch Hand

Joined: Jul 06, 2001
Posts: 54
Yes Servin, definitly.
Take care
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: capturing windows app's output
 
Similar Threads
Database connection
catching an exception thrown by a commandline app.
Lost on the classpath!
Runtime.exec()
Touch Screen Programming Languages