Sunday, September 23, 2007

JPype is alive! kinda ....

Despite a few false starts, I am still working on JPype. I haver recently undertaken to rewrite it again.

Last year was a major false start. The architectural goal of writing less C++ landed writing just as much (in glue code), but also write a lot more of glue java and python code. Best forgotten.

This time around, I decided to tackle the main issue first. So after doing minimal work on general class support, I tackled what I set out to do all those years ago : subclassing.

As of this writing, it works! With a few restrictions, it is possible to extend a java class in python, pass an instance of it to java code and have the java code call the python methods! Hurray!!!

With this release, I have also decided to get serious about multiple host language support. To this end, the main package has been renamed to JEmbed. It has a completely new API geared towards the new functionality.

JPype will continue to exist. My goal is to re-implement the JPype API on top of JEmbed such that existing programs will continue to work as-is.

I am also going to try an open approach to the progress. All the main tasks are listed on t he sourceforge project (JEmbed and JPype ). As things progress, I will add tasks there, and track their completion.

If anywone sees anything missing from there, or have requests to make, let me know! please open a feature request on the site ( )

Thats it for now.


Anonymous Laa said...

Hi, I try to run JPype in Python with mod_python. But it gives a bunch of errors. Seems like it is unable to attach to a JVM or sometimes start a new one and so on. Any advice? Please!

5:41 AM  
Blogger zsozso said...

I haven't tried JEmbed as I last worked with JPype this spring. I can only subscribe to the idea that such a project is very much justified, I would even dare to say that it is vital as both languages are mainstream. So, congrats, and please, keep up the great work!

If this is the place to write to Santa Claus in JPypeland I would ask for better error reporting. When Python calls Java that calls Python that calls Java, etc. runtime errors could only get spotted either by super verbose logging or after a tedious narrowing down of the suspicious code segments.

11:29 AM  
Blogger Steve Menard said...

Laa you problems with mod_python are interesting ... perhaps you'd like topost on the JPype mailing list? I haven't tried what you describe yet,and I am super the interestions between Apache, Python and JVM will make for interesting and educational situations. People there might be able to help you.

1:27 PM  
Blogger Steve Menard said...

Zsozso I am keeping up the work .. as best I can .. I find I don't have much use for python anymore, as the Java tools geatly reduced the advantages that python offers. Still, Jpype/Jembed is not dead!

Error reporting is a tough one .. chaining together Python stack trace and Java stack traces willnever be natural. AFAIK Python exception do not even have the concept of exception chaining. At best (and that's my current plan) I will stringify them and concatenate.

1:30 PM  
Anonymous zsozso said...

I am sorry to read that your interest in Python has somewhat faded. While being primarily a Java fan, I can't avoid Python that is becoming a fundamental (wrapping) language in scientific computing. I appreciate its high-level programming language features and its natural connection to C.

Any error reporting is better than none. So stringifying all stack traces would be great, thanks!

5:06 PM  
Anonymous Anonymous said...

Please, please, keep the project alive. I am starting a project which will rely heavily on JPype. Maybe, if I'll have time I can participate in JPype development.

3:55 PM  
Blogger Steve Menard said...

No worries, the project is far from dead. While it has seen more active periods, I am still maintaining and answering all questions. Even implementing some simple enhancements on the 0.5 codebase, as the PyPy team will soon be able to attest.

So rest easy!

4:06 PM  
OpenID korc said...

I'm using python daily for all my simple scripting needs, but I find it sometimes too relaxed and not suitable for high-level prototyping because of lacking features which java provides, like interfaces and such.
So I was thinking of using JPype as glue between python outside interface and java classes for doing actual job.
I'm wondering if I'm on the right track. Could you comment on what made you to not use python so much anymore?

6:18 AM  
Blogger Steve Menard said...

Quite simply, python tooling is not up to snuff.

The evolution of tools around Java is really impressive. Comparing just the languages, python is really a better language than Java. But add in the tools, and Java leaps ahead by miles. The refactoring support, code completion, etc ... that are missing (and nearly impossible to get right) on python make me feel like I am missing an arm.

Add to that that my recent endeavors are all Client GUIs delivered via Webstart ... and well I just don't have a place for it in my toolset anymore.

It may change though. Sun is investing in dymanic languages like Python, so maybe the tools support will catch up.

9:49 AM  
Anonymous Anonymous said...

Is there any plan for a port to Python v3?

10:12 AM  
Anonymous Anonymous said...

Is there any plan for a port to Python v3?

10:12 AM  
Blogger fisherman said...

Hi Steve, I'm trying to call Java APIs from Python program, and have tried JPype. It's great tool. But I didn't find license information on website? What's license JPype uses? Please reply me Thanks.

2:30 AM  
Blogger anupam said...

Hi, I am trying to install JPYpe0.5.3 in ubuntu linux. i have Python2.4 and Java1.4 already installed on my machine. when i am tying to install JPype, it gives the following error:
error: command 'gcc' failed with exit status 1

Please give me a solution in this regard.

6:34 AM  
Blogger Fraun said...

I'm really into this project too. But I must say that the (lack of) error reporting is a major obstacle.

I'm using JPype to create python proxy classes that implement interfaces in the Rhino scripting engine. This way, my C objects that have python bindings can appear as first-class objects in javaScript. (Pyspidermonkey was taking alot longer.)

Proxy support goes a long way (although py-over-java subclassing would be great). But somewhere along development, I get this "ArrayStoreException" with no traceback. I'm not an java expert, but it seems that this is an indirect kind of exception.

Also, there seemed to be some garbage with the stringified exception (I think I hacked something into jpype source to squeeze a little more out).

Somebody needs to pay Steve alot of money to work on this. Thanks for your effort!

6:57 PM  
Blogger Steve Menard said...

Thanks Fraun.

I freely admit JPype exception chaining leaves a lot to be desired. The current structure of JPype however doesn't not make it easier to make it better.

If you a java exception, you can call it's own printStackTrace(), that should give you all the info you need, or at least all the info you would get in pure java.

9:13 PM  
OpenID anshumanpandey said...

Hi Friends,
Iam having a major problem in my project. In the project the functions have to be published as web services(Using NetBeans for this).The problem is that the functions that have been developed are in python and the integration is not my cup of tea. So I need some help. NetBeans comes with a Python plugin(Jython or an already installed version of python can be selected). Iam not using Jython for obvious reason that some of the functionalities(like LXML which forms the backbone of my project) are not supported.
Please help. I need all the advice i can get

2:42 AM  
Blogger Steve Menard said...

Interesting problem.

Unfortunately at this time, JPype cannot help you. It's current aim is the opposite, exposing java function to Python, instead of what you need, exposing Python functions to java.

If you donlt have a hard requirement to use java technology for your web services, I suggest you look into pure-python solutions. Java is not the only way to do SOAP and REST services ;)

8:01 AM  
Blogger gnovosel said...

Hi. I just happen across JPype for the first time today, and I'm really impressed. I'd like to thank you for creating JPype. I also have a question. What's JPype's situation with py3k?

8:02 PM  
Blogger Steve Menard said...

Hi gnovosel, and thanks for your comment.

As to JPype's status Python 3.x ... that's not quite firm yet.

For sure, 0.5 will not be ported to Python 3 (at least, not by me).

I am however working on JPype 2, and one foe the goal of the initial release is to support Python 2.x and 3.x.

ETA for this version is currently impossible to say. My personal situation has prevented me from working on it for some time now.

11:24 PM  

Post a Comment

<< Home