• 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:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

getting output from DOS into GUI

 
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a few questions about the GUI interface. I have a program that executes a DOS command. How do I get the output from that command into my JTextArea in my panel in the GUI?? Also, is there a way when running a java app, to close the DOS window after the program starts??
I remember reading that when you execute commands from a Java app that it automatically puts the output to stderr. Is that true? How do I change its default output?
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There might be an easier way, but I know this works. You can write the output of a DOS command to a .txt file by redirecting the DOS output stream. For example, dir *.txt > output.txt will write the output of this dir command to a text file called output.txt. Then you could read that file into your GUI. > will overwrite any file with the same name. To append output from a DOS command to an existing file without overwriting, use >>.
With regard to the annyoing DOS window, see the thread on that subject in this forum.
 
ryan headley
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yeah I figured you could do that, but I would think there is a way around that. That seems like an awful lot of IO. There has to be a way to set stdout to an object in your GUI.
as far as the DOS thing from the other thread, that's pretty nifty!! I setup a shortcut to kick of the program so I don't even see a DOS screen at all! I've been having fun with that one.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic