July 27th, 2004, 11:05 AM
-
Python and Java
Hi everyone,
I have been using python for a while now and I want to develop a piece of software in java that call some of my python methods. I have already explored jython however it seems I would have to re-writed the python files however I was wondering if there is anyway in which I can call the python files from java (specifically JBuilder) without doing much changes to the python files.
Does anyone has any suggestions????
All help welcomed, thanks.
July 27th, 2004, 11:27 AM
-
I havnt done much work with Jython. But i really dont think you will have to rewrite any Python files, that is after all the point of it
. Jython should be able to use any Python file/library, or i don't see a reason why not anyway.
Unfortuantly I havn't heard of any other way of integrating Python with Java, so my best advice would be to give Jython a shot!
Mark.
July 27th, 2004, 01:25 PM
-
As netytan said, Jython is designed for this task and most Python scripts should run with little or no modification on Jython. The exception is scripts that use C extensions that have not be converted. Jython is also only at 2.1 at the moment, so 2.2 and later features will not work. A 2.2/2.3 release is supposed to happen later this year.
There are alternatives though. You could wrap your Python libraries in a wrapper like XML-RPC and run it as a server. Or use a CORBA orb, or SOAP or even COM. These all work in essentially the same way, with the Python running as a separate process and exposing the functionality to client programs that could be written in any language.
There was also JPI, a CPython <-> Java Interface, but it is no longer being developed and may take some effort to get working with the latest version of Python. You can find it at http://www.ndim.edrc.cmu.edu/dougc/jpi/Home.html.
Dave - The Developers' Coach
July 27th, 2004, 01:30 PM
-
I have also found JPE (http://sourceforge.net/projects/jpe) which is similar to JPI, and also no longer being actively developed.
And SPIRO, a Python -> Java Orb. http://www.freenet.org.nz/python/spiro/
Dave - The Developers' Coach
July 28th, 2004, 02:29 PM
-
Hi,
thanks for the reply, I installed jython a few weeks ago and then tried to run my python files but there were a number of errors, the way some methods are declared have to be rewritten for them to work.
Originally Posted by netytan
I havnt done much work with Jython. But i really dont think you will have to rewrite any Python files, that is after all the point of it

. Jython should be able to use any Python file/library, or i don't see a reason why not anyway.
Unfortuantly I havn't heard of any other way of integrating Python with Java, so my best advice would be to give Jython a shot!
Mark.
July 28th, 2004, 02:31 PM
-
Hi,
thanks for the reply, I thiink I will explore one of your suggestions, I am not too familiar on COM and SOAP but I will research them and give it a try if all else fails then its back to jython. Thanks
Originally Posted by DevCoach
As netytan said, Jython is designed for this task and most Python scripts should run with little or no modification on Jython. The exception is scripts that use C extensions that have not be converted. Jython is also only at 2.1 at the moment, so 2.2 and later features will not work. A 2.2/2.3 release is supposed to happen later this year.
There are alternatives though. You could wrap your Python libraries in a wrapper like XML-RPC and run it as a server. Or use a CORBA orb, or SOAP or even COM. These all work in essentially the same way, with the Python running as a separate process and exposing the functionality to client programs that could be written in any language.
There was also JPI, a CPython <-> Java Interface, but it is no longer being developed and may take some effort to get working with the latest version of Python. You can find it at http://www.ndim.edrc.cmu.edu/dougc/jpi/Home.html.
Dave - The Developers' Coach