473,537 Members | 2,796 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1679
"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
3452
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 "proves" something) to consider the next time the "Python makes developers more productive" thread starts up again. Background ========== An...
1
3014
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 diffs, sending/receiving, etc. One of these engines in implemented in C# and the other in Java. Now the choice comes down to which scripting...
46
6203
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
3271
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 connect several other "conventional" enterprise-applications such as ERP, SCADA etc. and to provide a GUI frontend to the users. The developers are...
114
9695
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
3490
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 objects/classes, some of which will have hundreds-of-thousands of instances stored in a DB. Our clients will probably have somewhere between 50-200 users...
2
1796
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 because I feel like whenever I want to do something in Java, I have to create an object, do a few preperatory things, then do what I need, but in...
30
2746
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 if anyone from the group could give me some advice on how to respond / if they had been in a similar position. Any help appreciated, Thanks in...
25
5709
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 advantages of one over the other in implementing this server.which language will be easier? What are the performance issues?In what language are...
17
2948
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 happened to notice that everything taught is using C++. After further research, it seems to me that C++ seems to be the dominating language in...
0
7298
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7683
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7275
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5824
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5218
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4844
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3345
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1757
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
578
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.