Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 27th, 2004, 11:05 AM
informed1 informed1 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 3 informed1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Post Python and Java

Hi everyone,

I have been using python for a while now and I want to develop a piece of software in java that call some of my python methods. I have already explored jython however it seems I would have to re-writed the python files however I was wondering if there is anyway in which I can call the python files from java (specifically JBuilder) without doing much changes to the python files.

Does anyone has any suggestions????


All help welcomed, thanks.

Reply With Quote
  #2  
Old July 27th, 2004, 11:27 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,536 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 3 m 4 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
I havnt done much work with Jython. But i really dont think you will have to rewrite any Python files, that is after all the point of it . Jython should be able to use any Python file/library, or i don't see a reason why not anyway.

Unfortuantly I havn't heard of any other way of integrating Python with Java, so my best advice would be to give Jython a shot!

Mark.
__________________
programming language development: www.netytan.com Hula


Reply With Quote
  #3  
Old July 27th, 2004, 01:25 PM
DevCoach DevCoach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2004
Location: London, England
Posts: 1,224 DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 5 Days 23 h 4 m 39 sec
Reputation Power: 263
As netytan said, Jython is designed for this task and most Python scripts should run with little or no modification on Jython. The exception is scripts that use C extensions that have not be converted. Jython is also only at 2.1 at the moment, so 2.2 and later features will not work. A 2.2/2.3 release is supposed to happen later this year.

There are alternatives though. You could wrap your Python libraries in a wrapper like XML-RPC and run it as a server. Or use a CORBA orb, or SOAP or even COM. These all work in essentially the same way, with the Python running as a separate process and exposing the functionality to client programs that could be written in any language.

There was also JPI, a CPython <-> Java Interface, but it is no longer being developed and may take some effort to get working with the latest version of Python. You can find it at http://www.ndim.edrc.cmu.edu/dougc/jpi/Home.html.

Dave - The Developers' Coach

Reply With Quote
  #4  
Old July 27th, 2004, 01:30 PM
DevCoach DevCoach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2004
Location: London, England
Posts: 1,224 DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 5 Days 23 h 4 m 39 sec
Reputation Power: 263
I have also found JPE (http://sourceforge.net/projects/jpe) which is similar to JPI, and also no longer being actively developed.

And SPIRO, a Python -> Java Orb. http://www.freenet.org.nz/python/spiro/

Dave - The Developers' Coach

Reply With Quote
  #5  
Old July 28th, 2004, 02:29 PM
informed1 informed1 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 3 informed1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi,

thanks for the reply, I installed jython a few weeks ago and then tried to run my python files but there were a number of errors, the way some methods are declared have to be rewritten for them to work.

Quote:
Originally Posted by netytan
I havnt done much work with Jython. But i really dont think you will have to rewrite any Python files, that is after all the point of it . Jython should be able to use any Python file/library, or i don't see a reason why not anyway.

Unfortuantly I havn't heard of any other way of integrating Python with Java, so my best advice would be to give Jython a shot!

Mark.

Reply With Quote
  #6  
Old July 28th, 2004, 02:31 PM
informed1 informed1 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 3 informed1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi,

thanks for the reply, I thiink I will explore one of your suggestions, I am not too familiar on COM and SOAP but I will research them and give it a try if all else fails then its back to jython. Thanks


Quote:
Originally Posted by DevCoach
As netytan said, Jython is designed for this task and most Python scripts should run with little or no modification on Jython. The exception is scripts that use C extensions that have not be converted. Jython is also only at 2.1 at the moment, so 2.2 and later features will not work. A 2.2/2.3 release is supposed to happen later this year.

There are alternatives though. You could wrap your Python libraries in a wrapper like XML-RPC and run it as a server. Or use a CORBA orb, or SOAP or even COM. These all work in essentially the same way, with the Python running as a separate process and exposing the functionality to client programs that could be written in any language.

There was also JPI, a CPython <-> Java Interface, but it is no longer being developed and may take some effort to get working with the latest version of Python. You can find it at http://www.ndim.edrc.cmu.edu/dougc/jpi/Home.html.

Dave - The Developers' Coach

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Python and Java


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT