接口的Jython库

时间:2014-06-13 17:47:12

标签: python interface jython java objectfactory

我正在通过this Jython指南制作一对一Jython对象工厂。

作者谈到他在整个教程中使用的org.jython.book.interfaces

  

为了使用这种技术来使用Jython模块,你必须这样做   要么确保.py模块包含在sys.path中,   或硬编码Java代码中模块的路径。   一个python模块,它实现了一个Java接口来创建一个构建对象

from org.jython.book.interfaces import BuildingType

我已经导入了我能找到的每个jython.jar,并且这部分库不存在。在他的教程中,他创建了building.pybuildingType.javabuildingFactory.java

以下是应用程序命中并无法继续运行的代码:

package my.irondb_datdiff;


import org.python.core.PyObject;
import org.python.core.PyString;
import org.python.util.PythonInterpreter;


public class DiffFactory {

  private PyObject diffClass;

  public DiffFactory() {
    PythonInterpreter pyin = new PythonInterpreter();

    pyin.exec("from make_diff_from_irons import make_diff_from_irons");
    diffClass = pyin.get("make_diff_from_irons");        

}

  public make_Diff run(String export, String source, String target) {

    PyObject diffObject = diffClass.__call__(
        new PyString(export),
        new PyString(source),
        new PyString(target));

    return (make_Diff)diffObject.__tojava__(make_Diff.class);

}

}

这就是它在执行“run”后命中的行:

from my.irondb_datdiff import make_Diff

我已经制作了我的这些版本,但是我得到了我的模块不存在的错误。我确定这是因为我没有导入界面,因为我在库中找不到合适的模块。

有什么想法吗?

(另外我发现另一张海报对本教程中的这个确切步骤有类似的问题,但这个问题不同,其他海报答案没有回答我的问题。所以请不要标记为重复。)< / p>

0 个答案:

没有答案