Executing a Jython function from Java

ProgDario dario at fga-software.com
Fri Sep 5 05:22:27 EDT 2003


Hello,

in the site I found a lot of complicated examples, but I can't find
the simple one I'm looking for.

The problem is:

I have 1 jython file (script1.py) with a function named 'calculate',
and a java file (run.java).

I'd like to call the jython function from the java class recursively.
<<====<<

I think it can be possible to get a PyFunction object that rapresents
the function, and then call the function from the already evaluated
object, so I don't need to re-evaluate it every loop.

My code is something like this:

PythonInterpreter interp = new PythonInterpreter();
interp.execfile('script1.py');
for (int i = 0; i < 1000; i++) {
interp.eval("calculate(8)");
}

Thanks in advance,

Dario




More information about the Python-list mailing list