Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Passing array from java to python

Reply
Thread Tools

Passing array from java to python

 
 
loial
Guest
Posts: n/a
 
      06-02-2011
I need to pass some sort of array or hashmap from Java and read the
data in a python script (which will be called by the java class). Is
there any neater way to do this other than just passing strings?

 
Reply With Quote
 
 
 
 
Chris Rebert
Guest
Posts: n/a
 
      06-02-2011
On Thu, Jun 2, 2011 at 2:54 AM, loial <(E-Mail Removed)> wrote:
> I need to pass some sort of array or hashmap from Java and read the
> data in a python script (which will be called by the java class). Is
> there any neater way *to do this other than just passing strings?


Jython?: http://www.jython.org/

Or depending on how you define "just passing strings", JSON:
http://json.org/
http://docs.python.org/library/json.html

Cheers,
Chris
 
Reply With Quote
 
 
 
 
loial
Guest
Posts: n/a
 
      06-02-2011
Unfortunately using jpython or json are not options at the moment
 
Reply With Quote
 
Chris Rebert
Guest
Posts: n/a
 
      06-02-2011
On Thu, Jun 2, 2011 at 3:47 AM, loial <(E-Mail Removed)> wrote:
> Unfortunately using jpython or json are not options at the moment


What rules out JSON that does not also rule out the "just passing
strings" approach?

What about (*shudder*) XML? (Can't believe I just said that...)

Cheers,
Chris
 
Reply With Quote
 
Ian Kelly
Guest
Posts: n/a
 
      06-02-2011
On Thu, Jun 2, 2011 at 4:47 AM, loial <(E-Mail Removed)> wrote:
> Unfortunately using jpython or json are not options at the moment


How about JPype? Or do the Java and Python need to be in separate processes?
 
Reply With Quote
 
Marco Nawijn
Guest
Posts: n/a
 
      06-03-2011
On Jun 2, 11:54*am, loial <(E-Mail Removed)> wrote:
> I need to pass some sort of array or hashmap from Java and read the
> data in a python script (which will be called by the java class). Is
> there any neater way *to do this other than just passing strings?


I recently had to deal with the same problem, some bi-directional
communication between Java and Python. Several options were discussed
between me and my fellow programmer. In the end we settled for XML-
rpc. It works remarkably well in our case. We use it to pass test and
simulation data to GUI code. XML-rpc is very well supported in python.
Basic types (lists, dicts etc.) are encoded automatically. If the
arrays are very large, I would probably use an intermediate database
(e.g. Hdf5) for storage and then use some sort of messaging to inform
the Java code of any changes.

 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing an array from FORTRAN to C then passing it within C andReturning it to FORTRAN deadpickle C Programming 1 11-07-2010 02:38 PM
Passing derived class object array in place of base class object array justanotherguy63@yahoo.com C++ 9 12-03-2004 10:57 PM
Passing a contiguously allocated 2D array to a function expecting a 1 dimesnional array Jonathan Underwood C Programming 2 08-13-2003 04:21 PM
Re: Passing pointer to array from C to Python..and modifying same array in python? J W Python 0 07-14-2003 02:59 PM
Passing pointer to array from C to Python..and modifying same array in python? JW Python 1 07-12-2003 10:45 PM



Advertisments