473,626 Members | 3,948 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 22326
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**********@v ideotron.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 interoperabilit y 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.pytho n 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_wrappe rs.py
=============== =====

``generate_wrap pers.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_wrap pers.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
3458
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 employee who left our company had written a log processor we use to read records from text files (1...
14
3290
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 into Struts, Enterprise Java Beans and the like, so it will be entirely implemented in Java with all...
14
1991
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 calls for proposals regularly. Proposals should be for specific projects with a clear objective, rather than support for ongoing activities. Proposals should be brief (a few pages of text), and they should explain: a. what the objective of the...
4
3421
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
9805
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
1424
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 to 6 January, to help all those folks who were concentrating on the PyCon deadline of 30th December. Recycled PyCon talks are acceptable. About the event
11
9239
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 C++. I find my self sometimes, trying Object app = Object(); Object *app = Object(); Object app = new Object();
3
3732
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 "xmlrpc_client.excute("handler_name.method", param)" to call the methods in my xml-rpc server written in java. But how can I call the methods in Python? I cannot creat a handler in my Python XML-RPC server.....
1
5093
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 * startJVM("C:\Program Files\Java\jdk1.6.0_12\jre\bin\client", "-ea", "-Djava.class.path=%s" % classpath) com =JPackage("CallJavaFromPython")
0
8638
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8505
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7196
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6125
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5574
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4092
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2626
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
1
1811
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1511
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.