【发布时间】:2021-03-13 07:28:10
【问题描述】:
我正在尝试将 Jython SDK 安装到 IntelliJ Java 程序中。如何才能做到这一点?我在这里默认安装了 Jython: C:\jython2.7.2 并安装了 Python for Windows 。选择此目录或其 bin,会出现此错误
所选目录不是 JDK 的有效主目录。
最后,我想使用 PythonInterpreter,
https://stackoverflow.com/a/8899042/15358601
PythonInterpreter interpreter = new PythonInterpreter();
interpreter.exec("import sys\nsys.path.append('pathToModules if they are not there by default')\nimport yourModule");
// execute a function that takes a string and returns a string
PyObject someFunc = interpreter.get("funcName");
PyObject result = someFunc.__call__(new PyString("Test!"));
String realResult = (String) result.__tojava__(String.class);
【问题讨论】:
标签: java python intellij-idea jython