How interesting you put this in the streams forum because streams are the SECOND part of the answer.
The first part is Runtime.getRuntime().exec( command ). This will run an external command. It's likely to tie you to one OS and requirements of external programs, but many people find they can live with those restrictions.
exec returns a Process object, which has some streams. You need to hook up and read the stdout and errout streams. We often make separate threads for the two readers. Search this forum or the threads forum for "streamgobbler" to find some neat examples posted in the past.
I don't know if all that made sense or left you scratching your head. See how far you can get with the JavaDoc and some code. Then show us the parts you understand the the parts you don't and we'll try to keep you moving forward.