Python: How can I execute a jar file through a python script

前端 未结 5 895
别跟我提以往
别跟我提以往 2020-11-27 15:04

I have been looking for an answer for how to execute a java jar file through python and after looking at:

Execute .jar from Python

How can I get my python (v

5条回答
  •  清酒与你
    2020-11-27 15:48

    With args: concrete example using Closure Compiler (https://developers.google.com/closure/) from python

    import os
    import re
    src = test.js
    os.execlp("java", 'blablabla', "-jar", './closure_compiler.jar', '--js', src, '--js_output_file',  '{}'.format(re.sub('.js$', '.comp.js', src)))
    

    (also see here When using os.execlp, why `python` needs `python` as argv[0])

提交回复
热议问题