I have a Java class library (3rd party, proprietary) and I want my python script to call its functions. I already have java code that uses this library. What is the best way to achieve this?
3 Answers
Can you run your current Python scripts under Jython ? If so, that's probably the best way, since the Java library can be exposed directly into Jython as scriptable objects.
Failing that, there are a number of solutions listed here.
1 Comment
The other answer is JPype, which allows CPython to talk to Java. It's useful if you can't switch to Jython.
Comments
There's also JCC which is not mentioned on the Caltech page.
Quote:
JCC is a C++ code generator that produces a C++ object interface wrapping a Java library via Java's Native Interface (JNI). JCC also generates C++ wrappers that conform to Python's C type system making the instances of Java classes directly available to a Python interpreter.
When generating Python wrappers, JCC produces a complete Python extension via the distutils or setuptools packages.