调用 Python 的 Java 代码:
//arguments to be passed to the script
String[] patchArguments = { patchFileDirectory,centralPatchStagePath,patchId,patchFileName, action };
//initialize the interpreter with properties and arguments
PythonInterpreter.initialize(System.getProperties(), System.getProperties(), patchArguments);
pythonInterpreter = new PythonInterpreter();
//invoke python interpreter to execute the script
pythonInterpreter.execfile(opatchScriptPath + opatchScript);
Traceback(最里面的最后一个):
文件“/scratch/app/product/fmw/obpinstall/patching/scripts/PatchUtility.py”,第 4 行,在?
ImportError:没有名为子进程的模块
但是子进程已经安装,如果我直接使用终端执行 python 文件,它就会运行python PatchUtility.py
更新:我发现了一些东西
Jython 有一些限制:
有许多不同之处。首先,Jython 程序不能使用用 C 编写的 CPython 扩展模块。这些模块通常具有扩展名为 .so、.pyd 或 .dll 的文件。
subprocess 是否在内部调用 C 扩展?