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
posted
0
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
posted
0
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
posted
0
Yes Servin, definitly. Take care
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.