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.
Joined: Jul 06, 2001
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
Joined: May 10, 2002
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?