python - How to import a java class i created in jython and call a method -
python - How to import a java class i created in jython and call a method -
i have made java class calls other java classes , prints screen. trying build python interface calls java class, runs 1 method within it, , terminates. cannot access method. have used line "import directory.directory2.myclass.java (and .jar , .class) made .jar file both raw code , .class file. none of these seem working. set sys.path.append point directory java files are. need convert java class file python module? , if how do that?
jython supports loading java classes if python modules. searches directories in sys.path
.class
files.
first, create sure java class has been compiled javac
.
then, sys.path.append(d)
, d
directory containing package. if class says package foo.bar;
@ top, , resides @ mydir/foo/bar/myclass.java
, must have mydir
in sys.path
(not 1 of subdirs of mydir
).
finally, import class via from foo.bar import myclass
. names between must match between python , java! you'll doing "from [package] import [class]".
java python jython
Comments
Post a Comment