调用python脚本并在java

时间:2017-03-24 00:21:48

标签: java python intellij-idea jython scriptengine

我正在尝试使用IntelliJ中的Java运行python脚本,如下所示:

public static void main(String[] args) throws ScriptException, IOException {

    StringWriter writer = new StringWriter(); //ouput will be stored here

    ScriptEngineManager manager = new ScriptEngineManager();
    ScriptContext context = new SimpleScriptContext();

    context.setWriter(writer); //configures output redirection
    ScriptEngine engine = manager.getEngineByName("python");
    engine.eval(new FileReader("test.py"), context);
    System.out.println(writer.toString()); 
}

在我的test.py中,当我尝试

时发生了错误
from suds import WebFault

我想知道如何在我的代码中安装和使用名为suds programmetrically的项目。我环顾四周但却找不到与此有关的任何内容。

项目现场: https://pypi.python.org/pypi/suds-jurko/0.4.1.jurko.5

谢谢。

0 个答案:

没有答案