Embedding the Jython Interpreter
By embedding the Jython interpreter in your own Java classes, you can run scripts from within your application, gaining control over the complete environment. That's important because few Java applications run from the command line.
You can find the Jython interpreter in the class org.python.util.PythonInterpreter.
You can use code like the following to initialize the Jython interpreter:
Properties props = new Properties();
props.put("python.home", pythonHome);
PythonInterpreter.initialize( System.getProperties(), props, new String[0]); interp = new PythonInterpreter(null, new PySystemState()); Note that this is Java code, not Python code. You must set the python.home system property.
Post a comment