【发布时间】:2014-11-28 15:58:48
【问题描述】:
所以我一直在使用 subprocess.call 从 Python 运行 jar 文件:
subprocess.call(['java','-jar','jarFile.jar',-a','input_file','output_file'])
它将结果写入外部 output_file 文件。 -a 是一个选项。
我现在想在 python 中分析 output_file 但想避免再次打开该文件。所以我想将 jarFile.jar 作为 Python 函数运行,例如:
output=jarFile(input_file)
我已经安装了 JPype 并让它工作了,我已经设置了类路径并启动了 JVM 环境:
import jpype
classpath="/home/me/folder/jarFile.jar"
jpype.startJVM(jpype.getDefaultJVMPath(),"-Djava.class.path=%s"%classpath)
现在卡住了……
【问题讨论】: