First you need to run the program. Convenient function for this:
def run_command(command): p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) return iter(p.stdout.readline, b'')
It will return iterability with all output lines.
And you can access the lines and print with
for output_line in run_command('java -jar jarfile.jar'): print(output_line)
add import subprocess as well, since run_command uses subprocess .
source share