|
From: Jeff A. <ja...@fa...> - 2013-09-25 18:56:56
|
For option 1. I meant the usual JNI pattern of some C code of your own with a Java counterpart that you can then call from Jython. It's not a trivial task, but probably the only way realistically. I've been working lately on the JLine integration into Jython, which is an example of JNI. As for option 2, browsing the source of JyNI just now, I find it hard to assess the maturity. At least there's an example: https://github.com/Stewori/JyNI/blob/master/JyNI-Demo/src/JyNIDemo.py But you'll have to adapt the source unless your name is stefan! I meant to include the list in my first reply, so thanks for reflecting back (and to Alex for confirming the limitation). Jeff Jeff Allen On 25/09/2013 11:40, Sneha Murganoor wrote: > Hi Jeff, > > Thanks Jeff.. > > I am still facing the problem after downloading JyNI and setting > CLASSPATH to JyNI.jar. > > I realize that only few modules as of now are supported by JyNI. > > I didn't understand your first option. Did you mean .. Java lib > wrapping cv2.so and wrapping that Java lib into python library.. > > Thanks, > Sneha > > > On Wed, Sep 25, 2013 at 1:04 PM, Jeff Allen <ja...@fa... > <mailto:ja...@fa...>> wrote: > > Hello Sneha: > > You can't call loadable library code like that from Jython. > (Conversely you can call JVM code in JAR files.) The library will > conform to CPython calling conventions, so you won't be able to > invoke it directly even from Java. > > I can think of two possibilities worth looking at, but I haven't > used either myself: > 1. Wrap the library with native code callable from Java and a > class that loads that library. (Easy to say!) > 2. http://www.jyni.org/ > > I'm surprised numpy works for you. Maybe it imports, but I'm > pretty sure numpy doesn't *work* under Jython since it too has a > native C part. > > Jeff Allen > > On 25/09/2013 06:13, Sneha Murganoor wrote: >> Hi, >> >> I am facing probs to import .so file using PythonInterperter from >> Java. >> >> From python: >> $ python >> Python 2.7.3 (default, Apr 10 2013, 06:20:15) >> [GCC 4.6.3] on linux2 >> Type "help", "copyright", "credits" or "license" for more >> information. >> >>> import cv2 >> >>> print cv2.__file__ >> /usr/lib/pyshared/python2.7/cv2.so >> >>> exit >> Use exit() or Ctrl-D (i.e. EOF) to exit >> >>> >> $ >> >> >> From Java: >> PythonInterpreter ie = new PythonInterpreter(); >> ie.exec("import cv2"); >> >> $ javac InterperterExample.java >> $java InterperterExample >> Exception in thread "main" Traceback (most recent call last): >> File "<string>", line 1, in <module> >> ImportError: No module named cv2 >> >> >> But importing other modules like numpy works perfectly fine. >> >> How to resolve this? >> >> Thanks, >> Sneha >> >> >> >> ------------------------------------------------------------------------------ >> October Webinars: Code for Performance >> Free Intel webinars can help you accelerate application performance. >> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from >> the latest Intel processors and coprocessors. See abstracts and register > >> http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk >> >> >> _______________________________________________ >> Jython-users mailing list >> Jyt...@li... <mailto:Jyt...@li...> >> https://lists.sourceforge.net/lists/listinfo/jython-users > > |