473,320 Members | 2,027 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,320 software developers and data experts.

How to call Java from Python?


Is JPE (the Python Java Extension) being used widely/actively?

I tried to build it (with Python 2.3.4, j2se 1.4 on Debian
GNU/Linux) and had quite a bit of trouble. And, then, the samples
did not run.

Is there another way to call Java code from Python?

The JPE project does not seem too active lately, or is it?

I need it to run in the Python environment, not the Java
environment. I want to be able to call Java methods from Python.
I don't believe that can be done with Jython, can it? Aren't I
right that Jython runs in the Java environment and on Java VM?

For example, from within the Quixote Web framework, I want to be
able to create Java objects and call their methods.

Thanks in advance for pointers.

Dave

--
Dave Kuhlman
http://www.rexx.com/~dkuhlman
Jul 18 '05 #1
6 22313
Dave Kuhlman wrote:
For example, from within the Quixote Web framework, I want to be
able to create Java objects and call their methods.


FWIW, i'm kind of in the same boat. i'm switching to python for web
apps, but would sure like to use some of my existing java classes until
time offers an opportunity to convert the code.
Jul 18 '05 #2
Dave Kuhlman wrote:
Is JPE (the Python Java Extension) being used widely/actively?

I tried to build it (with Python 2.3.4, j2se 1.4 on Debian
GNU/Linux) and had quite a bit of trouble. And, then, the samples
did not run.

Is there another way to call Java code from Python?

The JPE project does not seem too active lately, or is it?

I need it to run in the Python environment, not the Java
environment. I want to be able to call Java methods from Python.
I don't believe that can be done with Jython, can it? Aren't I
right that Jython runs in the Java environment and on Java VM?

For example, from within the Quixote Web framework, I want to be
able to create Java objects and call their methods.

Thanks in advance for pointers.

Dave


Seems like my project my project got started at the right time :)

Take a look at JPype http://jpype.sourceforge.net

it aims to do what JPE did (but work).

It is still early in development, and working on win32 exclusively for
now (the linux port should consist only of a few lines of code, but I do
not have a linux meachine readily available). If you have a little C
coding knowledge, you might even contribute it :)

What's more, your's truly is doing his best to answer question and fix
problems as they arise.

I hope this helps,

Steve Menard

Jul 18 '05 #3
Steve Menard wrote:

Seems like my project my project got started at the right time :)

Take a look at JPype http://jpype.sourceforge.net

it aims to do what JPE did (but work).

It is still early in development, and working on win32 exclusively for
now (the linux port should consist only of a few lines of code, but I do
not have a linux meachine readily available). If you have a little C
coding knowledge, you might even contribute it :)

What's more, your's truly is doing his best to answer question and fix
problems as they arise.

I hope this helps,

Steve Menard


I think there are quite a few of us who are excited about this project
and would like to see this happen. Unfortunately not all of us have the
time (or perhaps the skills) to contribute. If my schedule opens up I
am definitely up for helping out. My end goal - like yours - is to
write Eclipse plug-ins, with the ultimate achievement of a Python IDE in
Eclipse. pyDev is about as close as we have come - but I think it has
reached a 'plateau'.

Markus
Jul 18 '05 #4
Steve Menard <st**********@videotron.ca> writes:
Dave Kuhlman wrote:
Is JPE (the Python Java Extension) being used widely/actively?
I tried to build it (with Python 2.3.4, j2se 1.4 on Debian
GNU/Linux) and had quite a bit of trouble. And, then, the samples
did not run.
Is there another way to call Java code from Python?
The JPE project does not seem too active lately, or is it?
I need it to run in the Python environment, not the Java
environment. I want to be able to call Java methods from Python.
I don't believe that can be done with Jython, can it? Aren't I
right that Jython runs in the Java environment and on Java VM?
For example, from within the Quixote Web framework, I want to be
able to create Java objects and call their methods.
Thanks in advance for pointers.
Dave


Seems like my project my project got started at the right time :)

Take a look at JPype http://jpype.sourceforge.net

it aims to do what JPE did (but work).

It is still early in development, and working on win32 exclusively for
now (the linux port should consist only of a few lines of code, but I
do not have a linux meachine readily available). If you have a little
C coding knowledge, you might even contribute it :)

What's more, your's truly is doing his best to answer question and fix
problems as they arise.

I hope this helps,

Steve Menard


0. Yep, a lot of us need something like this.

1. You could add a link to JPE on the JPype website. Also, it may
have reusable code, idioms, patterns, etc. Broken or not, it was
apparently further along than JPype when it stopped.

2. I'm willing to help, but will have to do it off-hours, at home.
Specifically, the Linux (*NIX) port.

3. I get the impression that the win32-centric part is in javaenv.hpp,
with its use of HINSTANCE. Anything else come to mind?

4. If there are multiple people willing to help, are you setup to
project manage the effort? E.g.:
a) extending the developer's guide documentation as we learn more
b) regression tests
c) prioritizing and coordinating work teams

--
ha************@boeing.com
6-6M21 BCA CompArch Design Engineering
Phone: (425) 342-0007
Jul 18 '05 #5
There is a language interoperability project, which can by found at

http://www.llnl.gov/CASC/components/

"Babel: a tool for mixing C, C++, Fortran77, Fortran90, Python, and Java
in a single application. This is our cornerstone product, representing
90% of our effort. Babel is the foundation for a multilanguage
scientific compoenent framework. We are often called "The Babel Team"
because of this tool's visibility."

However google has not found any references to it
in the comp.lang.python newsgroup which is kind of
strange. Is nobody using it - here? Judging from their
documentation it seems quite reasonable to use
for scientific projects. When they have finished
the java-"server" integration it should even
be perfect.

ciao,
Dominic
Jul 18 '05 #6
Steve Menard wrote:

[snip]

Seems like my project my project got started at the right time :)

Take a look at JPype http://jpype.sourceforge.net

it aims to do what JPE did (but work).

It is still early in development, and working on win32 exclusively
for now (the linux port should consist only of a few lines of
code, but I do not have a linux meachine readily available). If
you have a little C coding knowledge, you might even contribute it
:)

What's more, your's truly is doing his best to answer question and
fix problems as they arise.

I hope this helps,

Steve Menard

JPype looks like the real solution to me. And, I hope to use and
help with it.

However, I'm on Linux. So, until JPype supports Linux, I've done
something a bit simpler (or maybe not) in the meantime, here is a
mini-announcement.

generate_wrappers.py
====================

``generate_wrappers.py`` generates support files that enable
Python to use the classes and methods in a Java source code file.

This facility requires and uses ``gcj``, "The GNU Compiler for the
Java Programming Language". It can be used only on platforms that
support ``gcj``, ``gcjh``, and ``libgcj``.

The basic strategy is the following:

1. Use ``gcjh`` to generate a header file for your Java class.

2. Write adapter classes, methods, and functions that use the CNI
(the Compiled Native Interface) API to talk to your Java class.

3. Use SWIG to create Python wrappers for your adapter classes,
methods, and functions.

4. Compile the resulting source code to produce Python extension
(a shared library) that you can be import from Python.

``generate_wrappers.py`` helps you by generating some of the files
you need and by generating a ``Makefile`` that generates others.
*But*, you will need to write the C/C++ adapter classes, methods,
and functions by hand yourself. And, this will require that you
know enough CNI to do so.

Where to get it -- You can find it at:

http://www.rexx.com/~dkuhlman/generate_wrappers.html
http://www.rexx.com/~dkuhlman/genera...rs-1.0a.tar.gz

I'm interested in any suggestions, criticisms, ideas, etc.

Dave

--
Dave Kuhlman
http://www.rexx.com/~dkuhlman
Jul 18 '05 #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...
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...
14
by: Martin v. Löwis | last post by:
The Python Software Foundation is seeking grant proposals for projects related to the further development of Python, Python-related technology, and educational resources. The PSF plans to issue...
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
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
0
by: pyuk2005 | last post by:
The UK Python Conference for 2005 will take place at the Randolph Hotel, Oxford on 20-23 April 2005. This is the FINAL CALL for talks. The original deadline of 26th December has been extended...
11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
3
by: evelyne0510 | last post by:
Hi all, I have created a XML-RPC model (with server and client) written in Java. I want to call the methods in another XML-RPC model written in Python. I know that in Java, I can use like...
1
by: hofsoc20 | last post by:
Hi, I am trying to call java methods from a python script. Jython is not an option. I have looked at using Jpype. Below is my code thus far: Jpype.py from jpype import * ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.