I try to call a python method from java, and made a very simple example. But I have an exception:
My py file (test.py)
def tmp():
return "test!!!!!"
My java code
PythonInterpreter interpreter = new PythonInterpreter();
interpreter.exec("import test");
PyObject someFunc = interpreter.get("tmp");
System.out.println(someFunc);
PyObject result = someFunc.__call__();
String realResult = (String) result.__tojava__(String.class);
System.out.println(realResult);
And I have this result, exception on line *PyObject result = someFunc.__call__();*, because someFunc is null
null
Exception in thread "main" java.lang.NullPointerException at
com.testing.Test.test(Test.java:936) at
com.testing.Test.main(Test.java:96)
Any idea?
interpreter.get("test.tmp");