Jython and python modules

You embed jython and you will use some Python-Modules somewere:

if you want to set the path (sys.path) in your Java-Code :

public void init() {
        interp = new PythonInterpreter(null, new PySystemState());

        PySystemState sys = Py.getSystemState();
        sys.path.append(new PyString(rootPath));
        sys.path.append(new PyString(modulesDir));
    }

Py is in org.python.core.

rootPath and modulesDir is where YOU want !

let rootPath point where you located the standard-jython-lib

Have a look at src/org/python/util/PyServlet.java in the Jython-Source-Code for example

Leave a Comment