My Java JAR executes fine in linux command line, and I would like to have it executed through a python script.
I get the following error when trying Popen
:
Error: Could not find or load main class jar
Any ideas?
What I've tried thus far:
Popen
with simple java
and -version
. checked.cwd
. Checked.Working Java call:
>>> javaCall = subprocess.Popen(['java', '-version'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
Failed command:
>>> javaCall = subprocess.Popen(['java', 'jar' ,
'abs/path/to/jar/abc.jar',
'arg 1', 'arg 2', 'arg 3'], cwd =
'/abs/path/where/jar and python files live', stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
>>> output, err = javaCall.communicate()
>>> print err
Error: Could not find or load main class jar
Any pointers I'm missing?
Missing a - in front of jar
javaCall = subprocess.Popen(['java', 'jar' ,
'abs/path/to/jar/abc.jar',
'arg 1', 'arg 2', 'arg 3'], cwd =
'/abs/path/where/jar and python files live', stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
>>> output, err = javaCall.communicate()
>>> print err
Error: Could not find or load main class jar
Change to: javaCall = subprocess.Popen(['java', '-jar' , ~~~