Link to home
Start Free TrialLog in
Avatar of jamie_lynn
jamie_lynn

asked on

What is the best way to call Java apis from CPython?

Hi,
My CPython client needs to connect and get data from a Java server which returns only Java objects.  There is a Java api to get this data.
What is the best way to call Java apis from CPython and convert the Java objects to CPython objects?

Thanks
Jamie
Avatar of -Richard-
-Richard-
Flag of United States of America image

How firmly commiitted are you to keeping your client as a CPython app?  From Jython this task would be trivial because Jython can natively interface with Java libraries and has built-in mechanisms for converting Java objects to Jython equivalents.   From CPython, II believe it would be challenging and time-consuming.   Quite possibly it would be more challenging and more time-consuming to create the Java interface you desire from CPython than it would be to convert your app to Jython.   The solution would probably involve C++ programming to the JNI (Java Native Interface).  There are people that have already gone this route and written libraries, but they don't look ready-for-prime-time to me.  Here's a link that talks about some of them:  http://wiki.cacr.caltech.edu/danse/index.php/Communication_between_Java_and_Python
I think people pretty much stopped trying to develop this kind of thing once Jython became established.  It's really the ultimate Java/Python solution.
Avatar of jamie_lynn
jamie_lynn

ASKER

Hi Richard,

I am pretty committed since I have a lot of apis from C libraries that I currently use.
Can Jython call C functions without having a JNI bridge?

Thanks
Jamie
ASKER CERTIFIED SOLUTION
Avatar of -Richard-
-Richard-
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Run Java as a separate process and use RPC to communicate.
Hi Mish
That would technically work, but I don't want to do run Java as a separate process... a little too much work and maintenance.  Thanks for the suggestion tho.

Thanks
Jamie
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial