3

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.)

2 Answers 2

4

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.

Sign up to request clarification or add additional context in comments.

Comments

-1

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?)

1 Comment

Thanks. As it happens, I am reasonably familiar both with extending/embedding CPython, and with JNI. However, I view doing things this way as the last resort due to the amount of work it'll require for every function/class I'll be exposing from CPython to Java. I was hoping some work has already been done by others to help ease the pain.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.