I have a .jar file that I need to execute via Python.
My current code is
import subprocess
subprocess.check_output(['java', '-jar', 'StatsCalc.jar'])
I printed out the error message:
Traceback (most recent call last):
File "C:\Users\ali\Documents\Java Stuff\RedditFitnessCalc\out\artifacts\RedditFitnessCalc_jar\pythonBotScript.py", line 6, in <module>
p = subprocess.check_output(['java', '-jar', 'RedditFitnessCalc.jar'])
File "C:\Program Files (x86)\Python 3\lib\subprocess.py", line 620, in check_output
raise CalledProcessError(retcode, process.args, output=output)
subprocess.CalledProcessError: Command '['java', '-jar', 'RedditFitnessCalc.jar']' returned non-zero exit status 2
When I run it, a window pops up and disappears instantly. It is a java program that has a GUI. I tried running it directly and with a batch file and both work fine.