我正在使用Eclipse将带有Jython脚本的Java应用程序导出到jar文件。当我在Eclipse IDE中运行代码时,Jython脚本会执行,但当我运行相同代码的jar文件时,它不会执行。
我使用以下命令从java函数执行jython脚本
PythonInterpreter interp = new PythonInterpreter();
interp.execfile(".com\\sample\\Script.py"); 我将Jython2.7jar作为外部jar包含在构建路径中,并在PyDeV透视图中使用相同的jar作为解释器。
发布于 2017-04-28 20:02:37
我会建议这样的代码修复:
InputStream stream = this.getClass().getClassLoader().getResourceAsStream(".com\\sample\\Script.py");
PythonInterpreter interp = new PythonInterpreter();
interp.execfile(stream);我希望这能解决你的问题!如果没有,请随时向我们提供更详细的信息,以调查您的问题。(可能会将System.out和System.err重定向到日志文件...)
https://stackoverflow.com/questions/43655759
复制相似问题