473,395 Members | 1,915 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,395 software developers and data experts.

use of Java modules

Hi,

I have a Python program that needs to interact with Java as follows:

1- A website supplied me java code that is able to perform some web
services;
2- my Python program triggers some events;
3- I would like to use that java code when an event is triggered, instead of
having to recode everything in Python;
4- I know nothing about java, don't even know what .jar .class and .java
files are used for;
5- I've checked Jython.org but I don't know if it is what I was looking for,
because, preferably, I wouldn't like to have to learn Java;
6- Example: is it possible to import a java function such as connect() and
use it in my Python program directly using parameters like:
z1=value1
z2=value2
if TRUE:
connect(z1,z2) <-- java function with z1 and z2
7- is it possible to have, as other example:
var1, var2 = JAVA_FUNCTION(z1,z2)

So,my question are:
is Jython the way to do it? if not, how?
are there tutorials for extreme begginers in using another language in
Python?

Luis
Jul 18 '05 #1
4 1837
If you use the Jython (www.jython.org) implementation of Python, you
can call to arbitrary java modules easily.

There have been various projects to let the C implementation of Python,
CPython, play with Java.
http://64.233.167.104/search?q=cache...n/spiro/&hl=en
http://jpype.sourceforge.net/
.. and probably others.

I don't have experience with any of these, I just know their names from
spending a long time in the Python community, as well as doing a little
bit of google searching before sending this post.

Jeff

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFBN2F3Jd01MZaTXX0RAuHCAJ0VrS+D+RCpGpHLqJ7ZT/PAt1I0CQCfdGxx
VX7OeDA5v+jTnpfweXT7iOc=
=15jW
-----END PGP SIGNATURE-----

Jul 18 '05 #2
Luis P. Mendes wrote:
Hi,

I have a Python program that needs to interact with Java as follows:

1- A website supplied me java code that is able to perform some web
services;
2- my Python program triggers some events;
3- I would like to use that java code when an event is triggered, instead of
having to recode everything in Python;
4- I know nothing about java, don't even know what .jar .class and .java
files are used for;
5- I've checked Jython.org but I don't know if it is what I was looking for,
because, preferably, I wouldn't like to have to learn Java;
6- Example: is it possible to import a java function such as connect() and
use it in my Python program directly using parameters like:
z1=value1
z2=value2
if TRUE:
connect(z1,z2) <-- java function with z1 and z2
7- is it possible to have, as other example:
var1, var2 = JAVA_FUNCTION(z1,z2)

So,my question are:
is Jython the way to do it? if not, how?
are there tutorials for extreme begginers in using another language in
Python?

Luis


There are actually many ways for python to use Java classes.

There is Jython. This works well if you python code is compatible. This
means any python libraries you use must be jython-compatible. Also,
python-language-wise, jython is still arounf puthon 2.1 afaik.

Secondly, tehre is JPype ( http://jpype.sourceforge.net ). It still
alpha (and even that can be termed generous hehe). This is my prefered
option, since I am it's developper hehe. In theory it should eventually
allow you to use any Java class as though it were a python class.

Thirdly there is spiro (http://www.freenet.org.nz/python/spiro/) I have
no experience with it, but I know it bridges the Python and Java VM by
using CORBA.

Lastly there was JPI, a interface generator that would expose specific
java classes to python. the website seems to be down though ...

All these solutions have one thing in common though ... you will have to
learn a bit about java. No so much as to need to program in it, but
enough to set up environment and classpath, etc ...

If you decide to use JPype, you get support for free ;)

Hope this helps,

Steve

Jul 18 '05 #3
Steve Menard wrote:

There is Jython. This works well if you python code is compatible. This
means any python libraries you use must be jython-compatible. Also,
python-language-wise, jython is still arounf puthon 2.1 afaik.

Secondly, tehre is JPype ( http://jpype.sourceforge.net ). It still
alpha (and even that can be termed generous hehe). This is my prefered
option, since I am it's developper hehe. In theory it should eventually
allow you to use any Java class as though it were a python class.

Thirdly there is spiro (http://www.freenet.org.nz/python/spiro/) I have
no experience with it, but I know it bridges the Python and Java VM by
using CORBA.

Lastly there was JPI, a interface generator that would expose specific
java classes to python. the website seems to be down though ...

All these solutions have one thing in common though ... you will have to
learn a bit about java. No so much as to need to program in it, but
enough to set up environment and classpath, etc ...

If you decide to use JPype, you get support for free ;)

Hope this helps,

Steve

Hello Steve,

I must thank you for your answer, as well as Jeff.

JPype really seemed what I was looking for. Now that you've told me (in the
SourceForge.net forum) that it's available in Linux, I'll try hard to use
it. For sure, we'll keep in touch!

From all the three projects, JPype seems to me, at least, as the one where
I'd have to learn less about Java. Correct me if I'm wrong.

Luis

Jul 18 '05 #4
Luis P. Mendes wrote:
Steve Menard wrote:

There is Jython. This works well if you python code is compatible. This
means any python libraries you use must be jython-compatible. Also,
python-language-wise, jython is still arounf puthon 2.1 afaik.

Secondly, tehre is JPype ( http://jpype.sourceforge.net ). It still
alpha (and even that can be termed generous hehe). This is my prefered
option, since I am it's developper hehe. In theory it should eventually
allow you to use any Java class as though it were a python class.

Thirdly there is spiro (http://www.freenet.org.nz/python/spiro/) I have
no experience with it, but I know it bridges the Python and Java VM by
using CORBA.

Lastly there was JPI, a interface generator that would expose specific
java classes to python. the website seems to be down though ...

All these solutions have one thing in common though ... you will have to
learn a bit about java. No so much as to need to program in it, but
enough to set up environment and classpath, etc ...

If you decide to use JPype, you get support for free ;)

Hope this helps,

Steve


Hello Steve,

I must thank you for your answer, as well as Jeff.

JPype really seemed what I was looking for. Now that you've told me (in the
SourceForge.net forum) that it's available in Linux, I'll try hard to use
it. For sure, we'll keep in touch!

From all the three projects, JPype seems to me, at least, as the one where
I'd have to learn less about Java. Correct me if I'm wrong.

Luis


humm that is actually hard to say ... Jython would probably require more
java knowledge. JPI and SPIRO I do not know enough about to say.

I forgot to mention an older project whose goal was very similar to
JPype. It is unmaintained but achieved greater featurefull-ness thaqn
JPype. It is JPE at http://jpe.sourceforge.net

Steve
Jul 18 '05 #5

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

Similar topics

4
by: angel | last post by:
A java runtime environment includes jvm and java class (for example classes.zip in sun jre). Of course jython need jvm,but does it need java class. Thanx
9
by: vegetax | last post by:
I was a java developer one year ago ,before i moved to python i realy liked it at the beggining, but i got very disapointed lately since my previus two python proyects where relatively big,and...
14
by: Joachim Boomberschloss | last post by:
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...
9
by: IchBin | last post by:
I am trying to get Java to work from within PHP. I have been looking at: http://us2.php.net/java The error and line of PHP code: $system = new Java('java.lang.System'); Fatal error: Class...
0
by: mashua | last post by:
please help me with the following tasks am currently trying to learn java but seems to be very hard i need help to solve the following problems you can email me at nairobian_0@yahoo.com. thanks in...
1
by: mashua | last post by:
am currently a student trying to learn java but the following tasks have proven to more than diffult please help me with the codes. TASK 1 A} To get a degree from a university , a student needs...
0
by: subhanjan | last post by:
I have few simple querries which I am unable to fix for the last few days.I want to integrate Java support for php5.1.6. 1)I edited the /etc/php.ini file with the following ...
2
by: psbasha | last post by:
Hi, Is anybody tried using JAVA interface as front end and Python modules in the back end?. If so ,how to integrate the JAVA code with Python modules? How JAVA and Jython are...
0
by: thinboy | last post by:
Im having trouble with a Java Home work. I have found the following classes are their anymore This system is intended to provide the school timetabler with information to support his/her...
2
by: ramprakashjava | last post by:
This is index.jsp page code: <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %> <%@ taglib...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
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
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,...

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.