所以我一直在使用 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)
我现在卡住了......