CPython from Java?

你。 提交于 2019-12-30 10:37:33

问题


I need to call CPython code from Java. What tools/APIs/libraries exist out there to help me do this?

Jython is not an option since the Python code is heavily dependent upon numpy.

edit 1: The main() function should be Java, not Python (i.e. I need to embed CPython into Java, not vice versa.)

edit 2: I should also mention that I'll be passing large numeric arrays between Java and Python and therefore a solution that brings the two into the same process space would be preferable (but not mandatory.)


回答1:


You can take a look at using Jepp to embed CPython into Java. Read documentation here.

edit: For windows the project has prebuilt binaries for Python 2.4, 2.5, and 2.6. For Linux/Unix systems, you have to build it yourself.




回答2:


You probably want to read the docs on embedding a CPython interpreter. Also, on how to load native libraries in Java (was that called JNI?)



来源:https://stackoverflow.com/questions/4278182/cpython-from-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!