473,396 Members | 1,970 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Python and Java

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.

Mar 6 '06 #1
6 1671
"JKPeck" <JK****@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.
Mar 6 '06 #2
JKPeck wrote:
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.


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

Kent
Mar 7 '06 #3
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.

Mar 7 '06 #4
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.

Mar 7 '06 #5
JKPeck wrote:
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.


JPype or CORBA/ICE.

Diez
Mar 7 '06 #6
"JKPeck" <JK****@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?

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.


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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dave Brueck | last post by:
Below is some information I collected from a *small* project in which I wrote a Python version of a Java application. I share this info only as a data point (rather than trying to say this data...
1
by: bezeee | last post by:
At my work we are in the process of building a tool to test an XML based API. Basically, XML in and XML out over http. Currently, there are two engines that do all of the schema validations, xml...
46
by: Jon Perez | last post by:
Can one run a 1.5 .pyc file with the 2.x version interpreters and vice versa? How about running a 2.x .pyc using a 2.y interpreter?
14
by: Wolfgang Keller | last post by:
Hello, as a non-developer I am currently participating in an industrial "research" project to develop a so-called "web application". This application serves at the same time as middleware to...
114
by: Maurice LING | last post by:
This may be a dumb thing to ask, but besides the penalty for dynamic typing, is there any other real reasons that Python is slower than Java? maurice
53
by: john67 | last post by:
The company I work for is about to embark on developing a commercial application that will cost us tens-of-millions to develop. When all is said and done it will have thousands of business...
2
by: Hal Vaughan | last post by:
I'm self taught and most of what I've been working on for the past several years has been entirely in Perl and Java. I've noticed that I can code about 5 times faster in Perl than Java, in part...
30
by: Stuart Turner | last post by:
Hi Everyone, I'm working hard trying to get Python 'accepted' in the organisation I work for. I'm making some good in-roads. One chap sent me the text below on his views of Python. I wondered...
25
by: abhinav | last post by:
Hello guys, I am a novice in python.I have to implement a full fledged mail server ..But i am not able to choose the language.Should i go for C(socket API) or python for this project? What are the...
17
by: MilkmanDan | last post by:
I'll be a college freshman this fall, attending Florida Institute of Tech studying electrical engineering. I was considering taking some classes in programming and computer science, and I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.