473,396 Members | 2,011 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.

Integration with java

Hello,

I am working on a project in Python, and I"m
currently
looking into the possibiliy of writing some of the
project"s modules in Java. Given that a large part of
the code is already written in Python, using the
standard libraries and several extension modules, I
am
trying to gauge the viability of integration with
Java
via Jython with minimal impact on present code, on
the
complexity of future code, and on deadlines!

I need to know in general how dirty it will be to
combine the two languages, and what the costs I
should
take into account are. I"m also interested to know if
there are any commonly accepted strategies to fully
switch project languages (I"m considering, in the
extreme case, to change it all into Java), and if
writing some modules in Java and replacing the rest
gradually makes sense.

Three more specific questions I thought of:
1. Is is possible to pack a Jython/Java program in a
py2exe-like fashion? Is it possible to pack in such a
way both Python, Jython and Java code?
2. Does transferring large data structures between
Java and Python code running by Jython have a
significant effect on memory? For example, would
passing the result of a large database query from
Java
to Jython, for further processing, cause the entire
data to be duplicated or something similar?
3. Did I miss anything fundemental?

Thanks!

Joe.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Jul 18 '05 #1
14 2827
Joachim Boomberschloss wrote:
the code is already written in Python, using the
standard libraries and several extension modules


One thing to keep in mind is that Jython does not
integrate CPython, instead it "understands" python code
directly. So if you have a C extension that works with python
it won't work with Jython.

My feeling is that if you had a lot of Java code written and
wanted to build on that with python Jython would be a better
fit than vice versa.

Istvan.
Jul 18 '05 #2
It is possible, though possibly painful, to call java modules from
CPython using JNI. This is more difficult than Jython integration, but
probably required if you want to keep using your extension modules.

The JNI tutorial is available at
http://java.sun.com/docs/books/tutor...1.1/index.html .

I probably would not take this approach unless java offered some
incredibly substantial benefit or I was integrating a complex python
system with a complex java sytem. I would also probably start by
creating a good C API to access the required java modules via JNI and
then use SWIG (http://www.swig.org/) to generate the python wrapper.

Of course if you can drop the extension modules you have already
written, accessing Java from Jython is just an import statement away.
Good luck,

Chris

Jul 18 '05 #3
How about this?
http://jpype.sourceforge.net/

(I haven't used it myself)

Jul 18 '05 #4
In article <sP********************@giganews.com>,
Istvan Albert <ia*****@mailblocks.com> wrote:
Joachim Boomberschloss wrote:
the code is already written in Python, using the
standard libraries and several extension modules


One thing to keep in mind is that Jython does not
integrate CPython, instead it "understands" python code
directly. So if you have a C extension that works with python
it won't work with Jython.

My feeling is that if you had a lot of Java code written and
wanted to build on that with python Jython would be a better
fit than vice versa.

Istvan.


There are other possibilities, though, including JPE
<URL: http://jpe.sourceforge.net >. I recommend the
original poster consider the latter.
Jul 18 '05 #5
Can someone summarize in a nutshell what is the
difference between JPype and JPE?
Jul 18 '05 #6
In article <34*************@individual.net>,
Jon Perez <jb********@wahoo.com> wrote:
Can someone summarize in a nutshell what is the
difference between JPype and JPE?


JPE's the original. It provided more functionality than JPype has
achieved so far, I believe (though that could change any day). I
think no one now maintains JPE.

Someone really ought to include a couple of sentences to that effect
on the front page of <URL: http://jpype.sf.net/ >.
Jul 18 '05 #7
Cameron Laird wrote:
In article <34*************@individual.net>,
Jon Perez <jb********@wahoo.com> wrote:
Can someone summarize in a nutshell what is the
difference between JPype and JPE?

JPE's the original. It provided more functionality than JPype has
achieved so far, I believe (though that could change any day). I
think no one now maintains JPE.

Someone really ought to include a couple of sentences to that effect
on the front page of <URL: http://jpype.sf.net/ >.


Well, Cameron summed it up pretty good :)

I'd add that The only major (and yes I know it is VERY major)
funtionailty missing in JPype is the ability to subclass Java classes in
Python.

On the other hand JPype will (soon) have functionality that JPE doesnt
have. Java arrays can already (in 0.4) be iterated as regular Python
collections. Version 0.5 will add that same behavior for Java
collections (Map, List, Set, Iterator).

Of course, the above is based on the JPE documentation, because I havent
been able to get JPE to work.

About Cameron's suggestion, sure. I'll do it as soon as I (or someone
else) can get both JPype and JPE to work so they can be compared through
more than just their respective documentation.

Steve
a.k.a devilwolf on sourceforge
Jul 18 '05 #8
Cameron Laird wrote:
Someone really ought to include a couple of sentences to that effect
on the front page of <URL: http://jpype.sf.net/ >.


Now I remember visiting this site, but never understood how it
actually worked. Examples such as:

from jpype import *
startJVM("d:/tools/j2sdk/jre/bin/client/jvm.dll", "-ea")
java.lang.System.out.println("hello world")
shutdownJVM()

in three different versions are the only code examples
that to show "complete" working snippets. I'm still
clueless as to how would one say share a list between
python and java.

Istvan.
Jul 18 '05 #9
Istvan Albert wrote:
Now I remember visiting this site, but never understood how it
actually worked. Examples such as:

from jpype import *
startJVM("d:/tools/j2sdk/jre/bin/client/jvm.dll", "-ea")
java.lang.System.out.println("hello world")
shutdownJVM()

in three different versions are the only code examples
that to show "complete" working snippets. I'm still
clueless as to how would one say share a list between
python and java.


A while ago there was a thread in c.l.p about using JPype to access JMS
from within Python. IIRC someone then contributed a more elaborate real
life example of how to do this. Search Google Groups for more details.

Regards,
Jan
Jul 18 '05 #10
Istvan Albert wrote:
Cameron Laird wrote:
Someone really ought to include a couple of sentences to that effect
on the front page of <URL: http://jpype.sf.net/ >.

Now I remember visiting this site, but never understood how it
actually worked. Examples such as:

from jpype import *
startJVM("d:/tools/j2sdk/jre/bin/client/jvm.dll", "-ea")
java.lang.System.out.println("hello world")
shutdownJVM()

in three different versions are the only code examples
that to show "complete" working snippets. I'm still
clueless as to how would one say share a list between
python and java.

Istvan.


I am sorry you find the site so confusing ... perhpas I shold post a
more complete example in a prominent location ...

To asnwer your question more fully, the jpype-specific cide is only for
looking up the Classes and startting/stopping the environment. For
everything else, Java objects and classes are used as regular Python
objects.

In version 0.4.x, the API mostly remain Java's. This means some of the
basic magic python methods have been mapped to java equivalent (like
__str__ mapped to toString() and __eq__ mapped to equals()).

If you have any questions, feel free to post them on the feedback list
on sourceforge. I check it every day and I try to answer as quickly as
possible.

Steve, aka devilwolf on sourceforge, maintainer of JPype
Jul 18 '05 #11
Istvan Albert wrote:
Joachim Boomberschloss wrote:
the code is already written in Python, using the
standard libraries and several extension modules
One thing to keep in mind is that Jython does not
integrate CPython, instead it "understands" python code
directly. So if you have a C extension that works with python
it won't work with Jython.


Also, Jython is several versions behind CPython, so any Python code
that uses generators or new-style division won't work either.
My feeling is that if you had a lot of Java code written and
wanted to build on that with python Jython would be a better
fit than vice versa.


I agree.

Jul 18 '05 #12
Dan Bishop wrote:
Istvan Albert wrote:
Joachim Boomberschloss wrote:

the code is already written in Python, using the
standard libraries and several extension modules


One thing to keep in mind is that Jython does not
integrate CPython, instead it "understands" python code
directly. So if you have a C extension that works with python
it won't work with Jython.

Also, Jython is several versions behind CPython, so any Python code
that uses generators or new-style division won't work either.

My feeling is that if you had a lot of Java code written and
wanted to build on that with python Jython would be a better
fit than vice versa.

I agree.

Also let's not forget that the PSF has funded a project that's intended
to help Jython get up to the curve - see
http://www.python.org/psf/grants/Jyt...t_Proposal.pdf. If that
project succeeds, and if 2.5 development *does* focus mostly on the
library, there's a sporting chance that Jython can be fully up to date
for the 2.5 release.

regards
Steve
--
Steve Holden http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/
Holden Web LLC +1 703 861 4237 +1 800 494 3119
Jul 18 '05 #13
Steve Menard wrote:
To asnwer your question more fully, the jpype-specific cide is only for
looking up the Classes and startting/stopping the environment. For
everything else, Java objects and classes are used as regular Python
objects.
Thanks for the response. Currently I don't need to use java but
in the past when I explored such a possibility I looked at jpype
and I was unable to understand from the documentation what it
actually does.

There is a lot of text there, but it is all concerning catching
errors or other subtleties. For a new visitor the most important
question is about how it works, what does it do, and how can it be
applied for the given problem.
everything else, Java objects and classes are used as regular Python
objects.


This is too generic. My question was a little more specific,
how would I pass a python list as an argument of a java class/method or
transform a java list into a python one? You don't have to
answer it here, I'm just pointing out the kind of
questions that I was unable to get an answer for on the jpype
website.

best,

Istvan.
Jul 18 '05 #14
Istvan Albert wrote:
Steve Menard wrote:
To asnwer your question more fully, the jpype-specific cide is only
for looking up the Classes and startting/stopping the environment. For
everything else, Java objects and classes are used as regular Python
objects.

Thanks for the response. Currently I don't need to use java but
in the past when I explored such a possibility I looked at jpype
and I was unable to understand from the documentation what it
actually does.

There is a lot of text there, but it is all concerning catching
errors or other subtleties. For a new visitor the most important
question is about how it works, what does it do, and how can it be
applied for the given problem.
> everything else, Java objects and classes are used as regular Python
> objects.


This is too generic. My question was a little more specific,
how would I pass a python list as an argument of a java class/method or
transform a java list into a python one? You don't have to
answer it here, I'm just pointing out the kind of
questions that I was unable to get an answer for on the jpype
website.

best,

Istvan.


I see what you mean. And I agree fully. I guess that's one more thing to
put on the TODO list hehe.

Thanks for the input.
Steve
Jul 18 '05 #15

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

Similar topics

4
by: Dan | last post by:
Hello all. I am currently working on a project for several Hospitals. The application is written in Java, and the database is either Oracle or MySql, depending on the client. For a while now,...
0
by: Stylus Studio | last post by:
DataDirect XQuery(TM) is the First Embeddable Component for XQuery That is Modeled after the XQuery API for Java(TM) (XQJ) BEDFORD, Mass.--Sept. 20, 2005--DataDirect Technologies...
0
by: John | last post by:
We are doing integration with an AS400 running websphere - webservices. When the customer (AS400) calls the .Net webservice the customers java code (every other request or so) throws the following...
0
by: Rithish | last post by:
OS : RHEL3 PHP version : 5.0.2 JDK version : 1.5.0.06 I have been trying to compile PHP with JAVA support for the past week, and all I have left to do is take a noose and hang myself. Of all...
8
by: Dave Potts | last post by:
Hi, I'm just starting a development project in Python having spent time in the Java world. I was wondering what tool advice you could give me about setting up a continuous integration...
1
by: YellowfinTeam | last post by:
Marketplace: Yellowfin reporting 3.1 with BIRT Integration Yellowfin is proud to announce the release of 3.1. The major theme of this release is enhanced integration capability. We have...
3
by: stien | last post by:
Hi, I'm looking for someon who can help me with a problem with the php/java integration...It just won't work.. Here are some data to describe the software/system I'm working with:...
3
by: 2b|!2b==? | last post by:
Die-hard C++ enthusiast hear (only been recently converted - actually dragged kicking and screaming to ASP.net). I have loads of C++ libraries - what is the technology/methodolgy that provides...
5
by: Hussein B | last post by:
Hi. Please correct my if I'm wrong but it seems to me that the major continuous integration servers (Hudson, CruiseControl, TeamCity ..) don't support Python based application. It seems they...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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
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,...
0
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...

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.