You could try this way:

  • Use Jython instead of CPython to write Python code http://www.jython.org.
  • Integrate Jython code with Java code through Apache Bean Scripting Framework http://commons.apache.org/bsf/

If you definitely need to use CPython, then Apache Trift could be interesting for you: http://thrift.apache.org/ So you could make additional scalable abstraction layer and integrate your Java code with different languages (not only Python)

If you need a really low-level interface you could look at JNI http://java.sun.com/docs/books/jni/ for investigation. But I think it will take a lot of time to integrate your code with CPython using JNI.

Answer from Vladislav Bauer on Stack Overflow
๐ŸŒ
motmaytinh
quytran.is-a.dev โ€บ 2019 โ€บ 06 โ€บ how-i-wrote-a-python-wrapper-for-java-implementation-of-vncorenlp
How I wrote a python wrapper for Java implementation of VnCoreNLP โ€ข Tran Ngoc Quy
tokenizer/ โ”œโ”€โ”€ .env # Virtual environment folder โ”œโ”€โ”€ __init__ # Python library files โ”œโ”€โ”€ models # VnCoreNLP models โ””โ”€โ”€ VnCoreNLP-1.1.jar # VnCoreNLP java lib
๐ŸŒ
GitHub
github.com โ€บ LeeKamentsky โ€บ python-javabridge
GitHub - LeeKamentsky/python-javabridge: Python wrapper for the Java Native Interface
Python wrapper for the Java Native Interface. Contribute to LeeKamentsky/python-javabridge development by creating an account on GitHub.
Starred by 117 users
Forked by 64 users
Languages ย  Python 93.1% | Cython 4.4% | C 1.5% | Python 93.1% | Cython 4.4% | C 1.5%
Discussions

how to write python wrapper of a java library - Stack Overflow
How can we write a python (with CPython) binding to a Java library so that the developers that want to use this java library can use it by writing only python code, not worrying about any Java code? More on stackoverflow.com
๐ŸŒ stackoverflow.com
Best way to combine Python and Java?
I've used JPype for a while. It also starts a JVM from python. Once set up, interoperating with Java is transparent. You can start the JVM in such a way that it can be debugged directly using remote debugging tools. More on reddit.com
๐ŸŒ r/java
82
60
October 29, 2022
Check out my Java Reddit API Wrapper

I disagree with your naming conventions: classes should start with an upper case letter and packages have no capitalization. Also, I think this would benefit from unit tests instead of a bunch of mains, and putting them into their own source tree (src/test/java/yourpackagehere).

More on reddit.com
๐ŸŒ r/java
43
56
May 25, 2016
Gum: the Gradle/Maven wrapper
๐ŸŒ r/java
2
0
June 1, 2020
๐ŸŒ
GitHub
github.com โ€บ thouis โ€บ Python-Java-Bridge
GitHub - thouis/Python-Java-Bridge: python wrapper for the Java Native Interface
python wrapper for the Java Native Interface. Contribute to thouis/Python-Java-Bridge development by creating an account on GitHub.
Author ย  thouis
๐ŸŒ
GitHub
github.com โ€บ agrias โ€บ javapy
GitHub - agrias/javapy: Python wrapper for Java/Scala using native libraries
July 11, 2019 - Python wrapper for Java/Scala using native libraries - agrias/javapy
Author ย  agrias
๐ŸŒ
GitHub
github.com โ€บ robocorp โ€บ java-access-bridge-wrapper
GitHub - robocorp/java-access-bridge-wrapper: Python wrapper around the Java Access Bridge Windows .dll ยท GitHub
Python wrapper around the Java Access Bridge / Windows Access Bridge.
Starred by 19 users
Forked by 8 users
Languages ย  Python 94.9% | Java 5.0% | Batchfile 0.1%
๐ŸŒ
GitHub
github.com โ€บ imperial-qore โ€บ pyJMT
GitHub - imperial-qore/pyJMT: Python wrapper for Java Modelling Tools
The pyJMT package is the official python wrapper for the Java Modelling Tools (JMT) suite, which is used for performance evaluation of systems using queueing network models.
Author ย  imperial-qore
Find elsewhere
๐ŸŒ
GitHub
github.com โ€บ CellProfiler โ€บ python-javabridge
GitHub - CellProfiler/python-javabridge: Python wrapper for the Java Native Interface
Python wrapper for the Java Native Interface. Contribute to CellProfiler/python-javabridge development by creating an account on GitHub.
Starred by 23 users
Forked by 13 users
Languages ย  Python 93.1% | Cython 4.4% | C 1.5% | Python 93.1% | Cython 4.4% | C 1.5%
๐ŸŒ
GitHub
github.com โ€บ fracpete โ€บ python-weka-wrapper
GitHub - fracpete/python-weka-wrapper: Python 2.7 wrapper for Weka using javabridge.
April 2, 2020 - Python wrapper for the Java machine learning workbench Weka using the javabridge library.
Starred by 83 users
Forked by 24 users
Languages ย  Python 98.2% | Java 1.4% | Python 98.2% | Java 1.4%
๐ŸŒ
Medium
medium.com โ€บ graalvm โ€บ supercharge-your-java-apps-with-python-ec5d30634d18
Supercharge Your Java Apps with Python | by Tim Felgentreff | graalvm
May 5, 2023 - In this article we look at an example application developed by students at the Hasso Plattner Institute (HPI) in Potsdam which can be used as a template for using Python libraries from Java on GraalVM. The full source code is available at the GitHub repository of the HPI Software Architecture Group.
๐ŸŒ
Python
wiki.python.org โ€บ moin โ€บ IntegratingPythonWithOtherLanguages
IntegratingPythonWithOtherLanguages
July 29, 2020 - bedevere - Python wrapper to GNU Prolog http://bedevere.sourceforge.net/ pwig includes examples of wrapping Python for SWI-Prolog. pyswip is a ctypes based module that enables querying SWI-Prolog. See also http://www.google.com/search?hl=en&lr=&ie=ISO-8859-1&q=Python+prolog ยท Jython - Python implemented in Java ยท
๐ŸŒ
Jython
jython.org
Home | Jython
There is work towards a Python 3 in the projectโ€™s GitHub repository. Jython implementations are freely available for both commercial and non-commercial use. They are distributed with source code under the PSF License v2. Jython is complementary to Java and is especially suited for the following tasks:
๐ŸŒ
Quora
quora.com โ€บ What-is-a-simple-example-of-wrapping-a-Java-library-with-Python
What is a simple example of wrapping a Java library with Python? - Quora
Answer: You could try this way: Use Jython instead of CPython to write Python code www.jython.org Integrate Jython code with Java code through Apache Bean Scripting Framework commons.apache.org/bsf/ If you definitely need to use CPython, then Apache Trift could be interesting for you: Apache T...
๐ŸŒ
GitHub
github.com โ€บ kedz โ€บ corenlp
GitHub - kedz/corenlp: A python wrapper for the Stanford CoreNLP java library.
A python wrapper for the Stanford CoreNLP java library.
Starred by 18 users
Forked by 7 users
Languages ย  Python 80.4% | Java 19.6% | Python 80.4% | Java 19.6%
๐ŸŒ
Reddit
reddit.com โ€บ r/java โ€บ best way to combine python and java?
r/java on Reddit: Best way to combine Python and Java?
October 29, 2022 -

My project uses some packages that are available only in Python and heavily rely on C libraries. The project also greatly benefits from Java libraries and the JVM. What's the optimal way to call Python functions from Java?

I tried:

  1. Small web-services: overhead to serialize data, start and stop the services. Also debugging is harder and implementing each new function is now double the effort.

  2. Jpy: a library that runs an interpreter in the JVM. Spare the service start/stop, but: isn't really feasible for more than a single-liner, data translation between Java and Python is cumbersome, and I also encountered runtime segmentation fault errors.

Any other options?

The project is in the machine-learning domain, so involves exchanging large numeric arrays and text. In some cases the execution switches back and forth between the platforms.

๐ŸŒ
Huihoo
docs.huihoo.com โ€บ homepage โ€บ dkuhlman โ€บ generate_wrappers.html
Python/Java Wrapper Generator - Huihoo
generate_wrappers.py generates support files that enable Python to use the classes and methods in a Java source code file.
๐ŸŒ
Py4j
py4j.org
Welcome to Py4J โ€” Py4J
Py4J also enables Java programs to call back Python objects.