What are the basic nuts and bolts of calling (running? interpreting? what can you do?) Python code from a Java program? Are there many ways to do it?
3 Answers
You can embed Jython within your Java application, rather than spawning off a separate process. Provided your library is compatible with Jython, that would seem the most logical place to start.
2 Comments
jjujuma
So are you saying that it's possible that a library might not be Jython-compatible?
Brian Agnew
Yes. I've edited my answer to provide a link to the Jython/CPython compatibility info
And if none of the other alternatives mentioned (Jython, Spring) work, you can always run an external CPython interpreter and communicate with the JVM through:
- CORBA
- Sockets
- Pipes
- Temporary files
Also maybe you would take a look at OpenOffice's UNO... I think it could be used outside the suite.