How would you do this if you want a mechanism that is portable across
Windows, Linux, Mac, and Unix?
Any ideas? Jython would be a natural candidate, but it is stuck at
Python 2.1 and seems to have an uncertain future.
Thanks in advance.
I suppose you could make some layer that sits between JNI and Python's
C API. It may be easier to use some slower IPC mechanism like
sockets, if you can tolerate that.
Jython 2.1 works great and there is (slow) progress being made in
modernizing it. I recommend it.
Kent
There are a number of ways you can use Java code through Python.
Use JPype to start a Java VM
http://jpype.sourceforge.net/
Or compile using GCJ and expose as a DLL/SO or better yet, make a SWIG
extension.
A good example for this is PyLucene.
Python/Java Wrapper Generator
http://www.rexx.com/~dkuhlman/generate_wrappers.html
simplifies the process.
Or use some standard interop mechanism. Write an XMLRPC/SOAP/CORBA and
script via Python. This is similar to the COM approach.
Or maybe, you can look into XPCOM. I have no experience with it.
And finally a bit more perverse approach that I used once. Converted
Java bytecode to CIL with IKVM.
http://www.ikvm.net/
And then I used Python for .NET
(http://www.zope.org/Members/Brian/PythonNet), a really well
implemented integration module if I ever saw one, to access the code.
Since the Java code is for a very large, complex application, we need
to bring Python to Java rather than Java to Python.
We will take a look at some of the other ideas.
JPype or CORBA/ICE.
Diez
If you need real CPython (e.g., need add-on libraries compiled in C),
then XMLRPC is a clean way to make the connection.