Calling python from Java?
Posted
by griffin
on Stack Overflow
See other posts from Stack Overflow
or by griffin
Published on 2010-04-20T00:23:26Z
Indexed on
2010/04/20
0:33 UTC
Read the original article
Hit count: 472
I'm trying to call Jython from a Java 6 application using javax.script
:
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
public class jythonEx
{
public static void main (String args[]) throws ScriptException
{
ScriptEngineManager mgr = new ScriptEngineManager();
ScriptEngine pyEngine = mgr.getEngineByName("python");
try {
pyEngine.eval("print \"Python - Hello, world!\"");
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
This is causing a NullPointerException:
java.lang.NullPointerException
at jythonEx.main(jythonEx.java:12)
Does anyone have any idea what I'm doing wrong here?
© Stack Overflow or respective owner