I'm working through this Jython
guide to make a one-to-one Jython
Object Factory.
The writer speaks of a org.jython.book.interfaces
that he uses through out the tutorial.
In order to utilize a Jython module using this technique, you must either ensure that the .py module is contained within your sys.path, or hard code the path to the module within your Java code. A python module that implements a Java interface to create a building object
from org.jython.book.interfaces import BuildingType
I've imported every jython.jar
I could find, and this part of the library does not exist. In his tutorial, he creates a building.py
, buildingType.java
, and a buildingFactory.java
.
Here is my code where the app hits and fails to keep running:
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);
}
}
And here is the line it hits that it files on after doing "run":
from my.irondb_datdiff import make_Diff
I've made my versions of these, but I get the error that my module does not exist. I'm sure this is because I'm not importing the interface because I can't find the right module in the library.
Any thoughts?
(Also I realize a another poster had a similar question about this exact step in the tutorial, but this question is different and the other posters answer didn't answer my question. So please don't mark as duplicate.)