Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Python and Java

12 views
Skip to first unread message

JKPeck

unread,
Mar 6, 2006, 6:01:33 PM3/6/06
to
Suppose you have an application written in Java, and you want to enable
other applications or processes written in Python to communicate with
it, i.e., to use Python as a scripting language for the application.
On Windows you could do this with COM and various addons such as
J-Integra and Mark Hammond's libraries.

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.

Paul Rubin

unread,
Mar 6, 2006, 6:04:54 PM3/6/06
to
"JKPeck" <JKP...@gmail.com> writes:
> Suppose you have an application written in Java, and you want to enable
> other applications or processes written in Python to communicate with
> it, i.e., to use Python as a scripting language for the application.
> On Windows you could do this with COM and various addons such as
> J-Integra and Mark Hammond's libraries.
>
> How would you do this if you want a mechanism that is portable across
> Windows, Linux, Mac, and Unix?

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.

Kent Johnson

unread,
Mar 6, 2006, 8:10:16 PM3/6/06
to

Jython 2.1 works great and there is (slow) progress being made in
modernizing it. I recommend it.

Kent

Ravi Teja

unread,
Mar 6, 2006, 10:51:00 PM3/6/06
to
For most purposes Jython 2.1 is just fine. The lack of recent features
is not a show stopper. What do you need metaclasses? decorators? BTW,
there is Jython 2.2 as an alpha release.

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.

JKPeck

unread,
Mar 7, 2006, 9:07:43 AM3/7/06
to
Thanks for these suggestions. To be clear, we already have a Python
2.4 minimum requirement for other reasons, and we are looking for a
long-term solution so that as Python advances, the scripting solution
can keep up in a timely way.

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.

Diez B. Roggisch

unread,
Mar 7, 2006, 9:14:29 AM3/7/06
to
JKPeck wrote:

JPype or CORBA/ICE.

Diez

Harry George

unread,
Mar 7, 2006, 1:23:43 AM3/7/06
to
"JKPeck" <JKP...@gmail.com> writes:

If you need real CPython (e.g., need add-on libraries compiled in C),
then XMLRPC is a clean way to make the connection.

0 new messages