Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

capturing windows app's output

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Servin Park
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes Servin, definitly.
Take care
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic