6 ms·
Pyjnius: Accessing Java classes from Python
- __mharrison__ 14y agoInteresting. It would be great to see some docs touching on pros/cons vs jython, jpype, etc I for one am interested in keeping everything in cpython if possible. But I currently have a web service in jython...
- tehansen 14y agoDeocumentation: http://pyjnius.readthedocs.org/en/latest/index.html http://pyjnius.readthedocs.org/en/latest/index.html
- ikusalic 14y agoI've used JPype in the past, but unfortunately it seems pretty much dead. This looks really promising. Thank you for the hard work.
- jpdus 14y agoLooks good! Has anyone tried this for accessing a Java Socket API? (e.g. Interactive Brokers API) Im currently using Jython but would love to switch to "real" Python, unfortunately i am still a noob when it comes to get these things working..
- jaytaylor 14y ago@jpdus Will you elaborate on why you are eager to ditch Jython in favor of CPython? I guess I have a soft spot for Jython. Overall this project looks very interesting- Can't wait to go through the source code at https://github.com/kivy/pyjnius https://github.com/kivy/pyjnius to see how this works under the hood. Cheers.
- txprog 14y agoMostly JNI, plus using our core class to use the java.reflect and discover methods and fields (you can't do it in JNI :/)
- jpdus 14y ago@jaytaylor The main reason for my part is that most/all my projects are pure python so far and im way more familiar with (C)Python and its libraries (numpy/scipy fe), dependencies, etc. than i am with Java. I like Jython too, but if i had the opportunity to do everything in pure Python i would ditch it nevertheless!
- bendemott 14y agoVery promising, thanks for the great work!
- koenigdavidmj 14y agoHow does it handle the two types of exception?
- txprog 14y agoWhen an exception from Java side is throw, we catch it, and raise our own JavaException python class.
- mahmoudimus 14y agoThis is pretty much a perfect example of when to leverage import hooks.
- tocomment 14y agoCan you explain that a bit more?
- d0mine 14y agoSo that you could: from java.util import Stack Instead of: from jnius import autoclass Stack = autoclass('java.util.Stack') http://www.doughellmann.com/PyMOTW/sys/imports.html#custom-importers http://www.doughellmann.com/PyMOTW/sys/imports.html#custom-i...
- txprog 14y agoSomeone on reddit asked for it, we'll do it.
- 3amOpsGuy 14y agoDoes this mean we now have a convenient way to speak JMX from python? That would be very handy!
- jnazario 14y agowhat's wrong with JCC? http://lucene.apache.org/pylucene/jcc/index.html http://lucene.apache.org/pylucene/jcc/index.html i have used it a lot to generate JNI bindings for other code via a simple Makefile template (list JARs and packages, alter names and versions, and poof). it works quite often, but it does run into some wonky C++ code it can't quite figure out. still, pretty easy. one example are some (work-private) mahout bindings.
- kbd 14y agoHow are generics handled?