Yes I wanted to be able to to have the output in the Jframe and be able to do the input also if that is possible. Not real familiar with the GUI so not sure what is possible. Was just trying not to have the external console pop up and have it run in it.
Well, you can get the output and input streams from the Process you're working with. I'm not sure if that'll prevent the console from popping up, but it still means you should be able to manipulate the process through your own GUI. Read through the article I linked to, and experiment a bit with it.
Yeah, the Gobbler described in the above linked article will give the details about how to consume the output. A similar principle can be used to provide input. The popping up of the command window comes from your use of the "start" command. See the microsoft documentation: here. "start" is specifically used to open a new command window. You should try to run the batch file without the start command. If you can't (I am not sure if start is necessary for running batch files) then you should use one of the command options to change window's behavior, such as using "start /b TheBatch.bat" or "start /min TheBatch.bat".
Joined: Oct 26, 2011
Cool thanks guys, I will start looking through the info and post if I have any other questions.
Joined: Oct 26, 2011
Ok guys so after looking through all that info, I would use the Gobbler to redirect the input and output to a text area in the Jframe right? I have never used it before so just want to make sure I am looking at it right and not missing anything. Also will I be using the BufferedReader with this?
The Gobbler will be used to consume the Process' output and error streams. You would have to modify it to append the data into your text area. A BufferedReader could definitely be used here. A couple things to point out:
- You should have two separate gobblers, one for the output and one for the error streams.
- The gobblers should each run in their own thread. They should push the text field update into the swing event thread, maybe using SwingUtilities
The input doesn't really need a gobbler or its own thread. You would have an input source on your GUI and an event listener for when the input is made. Then you would pipe the text the user entered into the Process' input stream.