Wiki's tutorial has some instructions as to how call java constructors / java methods from python:
# importing the java.lang.Class objects
from java.lang import Integer
from java.util import ArrayList as AL
# instantiation
x = Integer(5)
y = Integer(51)
a = AL()
I created a very simple python script that instantiates a custom class (test.py):
# importing the java.lang.Class objects
from mypackage import car
# instantiation
x = Car(5)
and tried to run on intellij:
import mypackage.Car;
import jep.Jep;
public class FirstVersion {
public static void main(String[] args) {
try (Jep jep = new Jep()){
// this works
Car c = new Car(5);
System.out.println("Java: " + c.n);
// this doesn't
jep.runScript("/home/ubuntu/test.py");
} catch (Exception e) {
System.out.println(e);
}
}
}
and got following error:
Java: 5
jep.JepException: <class 'ModuleNotFoundError'>: No module named 'mypackage'
Process finished with exit code 0
Is this possible? If so, what am I doing wrong?
Thank you,