I am currently working on a simple hello world program using jython and java.
The program is designed in way that a jython method accepts a name parameter and returns welcome message.
My problem is whenever I am accessing the jython method from java, it shows nullponter exception
My jython Script (JythonHello.py):
class JythonHello:
def __init__(self, name):
self.name = name
def sayHello(self):
return "Hello "+ self.name
and my java code:
public static void main(String[] args) {
PythonInterpreter interpreter = new PythonInterpreter();
interpreter.execfile("src/jython/JythonHello.py");
PyObject callFunction = interpreter.get("sayHello");
PyObject result = callFunction.__call__(new PyString("Boban"));
String msg = (String) result.__tojava__(String.class);
System.out.println("output: " + msg);
}
Any suggestions?