recieve output from java python

Solutions on MaxInterview for recieve output from java python by the best coders in the world

showing results for - "recieve output from java python"
Evan
04 Mar 2017
1import os.path,subprocess
2from subprocess import STDOUT,PIPE
3
4def compile_java(java_file):
5    subprocess.check_call(['javac', java_file])
6
7def execute_java(java_file, stdin):
8    java_class,ext = os.path.splitext(java_file)
9    cmd = ['java', java_class]
10    proc = subprocess.Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT)
11    stdout,stderr = proc.communicate(stdin)
12    return stdout
13
14compile_java('helloworld.java')
15java_output = execute_java('helloworld.java', 'args')
16
similar questions
queries leading to this page
recieve output from java python