You could also use Py4J. There is an example on the frontpage and lots of documentation, but essentially, you just call Java methods from your python code as if they were python methods:

from py4j.java_gateway import JavaGateway
gateway = JavaGateway()                        # connect to the JVM
java_object = gateway.jvm.mypackage.MyClass()  # invoke constructor
other_object = java_object.doThat()
other_object.doThis(1,'abc')
gateway.jvm.java.lang.System.out.println('Hello World!') # call a static method

As opposed to Jython, one part of Py4J runs in the Python VM so it is always "up to date" with the latest version of Python and you can use libraries that do not run well on Jython (e.g., lxml). The other part runs in the Java VM you want to call.

The communication is done through sockets instead of JNI and Py4J has its own protocol (to optimize certain cases, to manage memory, etc.)

Disclaimer: I am the author of Py4J

Answer from Barthelemy on Stack Overflow
🌐
SnapLogic
snaplogic.com › home › python vs. java: what’s the difference?
Python vs. Java: What's the Difference?
December 14, 2023 - Java, conversely, is lauded for its portability and robust performance, making it a stalwart in enterprise environments. ... Python, an interpreted language, blossoms in an environment where simplicity and rapid development are paramount. Its syntax is clean and easy to understand, making it especially friendly for beginners.
🌐
LinkedIn
linkedin.com › pulse › integrating-python-java-guide-developers-myexamcloud-7g5bc
Integrating Python and Java: A Guide for Developers
December 26, 2023 - Jython is an implementation of Python that runs on the Java Virtual Machine (JVM). It allows developers to seamlessly use Python code within a Java application and enables interoperability between the two languages.
Discussions

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
Suggestion: should I learn python or java?
If your company uses Java, I don't know why you wouldn't want to learn Java. Do you want to advance at your company? It doesn't sound like they need Python developers. More on reddit.com
🌐 r/learnprogramming
29
8
August 3, 2024
Python ou Java?
Java vai te dar uma base mais robusta pra aprender qualquer outra linguagem. Python tem a fama de ser "mais fácil" e pode te deixar mais fraco, sem ódio, com pouca cicatriz pra vida dura. More on reddit.com
🌐 r/programacao
55
2
September 6, 2024
Java vs. Python as first language pros and cons.
You just need to learn programming, if Java in your network is used more then start with Java. More on reddit.com
🌐 r/learnprogramming
40
27
December 29, 2024
🌐
Quora
quora.com › When-programming-in-Python-is-Java-necessary
When programming in Python, is Java necessary? - Quora
Answer (1 of 7): It's important to make a distinction between the language Java, and JVM. The latter has advantages in deployment over Python, including performance, stability, and threading. Java-the-language is a different issue; but there are now many modern languages available on the JVM, in...

You could also use Py4J. There is an example on the frontpage and lots of documentation, but essentially, you just call Java methods from your python code as if they were python methods:

from py4j.java_gateway import JavaGateway
gateway = JavaGateway()                        # connect to the JVM
java_object = gateway.jvm.mypackage.MyClass()  # invoke constructor
other_object = java_object.doThat()
other_object.doThis(1,'abc')
gateway.jvm.java.lang.System.out.println('Hello World!') # call a static method

As opposed to Jython, one part of Py4J runs in the Python VM so it is always "up to date" with the latest version of Python and you can use libraries that do not run well on Jython (e.g., lxml). The other part runs in the Java VM you want to call.

The communication is done through sockets instead of JNI and Py4J has its own protocol (to optimize certain cases, to manage memory, etc.)

Disclaimer: I am the author of Py4J

Answer from Barthelemy on Stack Overflow
🌐
Snowflake
snowflake.com › en › fundamentals › python-vs-java
Python vs. Java: Key Differences & Use Cases
August 4, 2025 - Understand Python vs. Java, learn the key differences in speed and ease of use. Explore popular use cases and strengths for each language.
Find elsewhere
🌐
Jython
jython.org
Home | Jython
The Jython project provides implementations of Python in Java, providing to Python the benefits of running on the JVM and access to classes written in Java. The current release (a Jython 2.7.x) only supports Python 2 (sorry).
🌐
AskPython
askpython.com › home › how to call java using python with jpype and pyjnius
Calling Java using Python | #1 guide to Jpype
November 8, 2023 - #1 Guide to learn how to use Jpype1 and Pyjnius to Call Java using Python by making use of JPype1 and Pyjnius in Python.
🌐
GeeksforGeeks
geeksforgeeks.org › java › integrating-java-with-python
Integrating Java with Python - GeeksforGeeks
July 23, 2025 - Packages like Py4j, Pyjnius, Jpype, javabridge, and JCC help invoke Java programs from Python. Also, since Java provides a wide variety of collections, we can directly use them in a Python program by including their java packages in the program.
🌐
Baeldung
baeldung.com › home › java › how to call python from java
How to Call Python From Java | Baeldung
August 27, 2025 - We can use the pluggable script engine architecture for any dynamic language provided it has a JVM implementation, of course. Jython is the Java platform implementation of Python which runs on the JVM.
🌐
Sololearn
sololearn.com › en › Discuss › 207244 › python-to-java
Python to Java | Sololearn: Learn to code for FREE!
Python is regarded as one of the easiest languages to learn, but the python learning section was longer and harder than java. I will redo the Python lesson soon as the last half was hard to wrap my head around. ... Yeah, Python is very easy to learn. I didn't like it earlier but now I'm into it.
🌐
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.

🌐
Java Programming
java-programming.mooc.fi
About the course - Java Programming
You can find our current Python course here · During this course, you will learn the basics of computer programming, along with algorithms and object-oriented programming through the Java programming language. The course includes comprehensive materials and plenty of programming exercises - all of which are tested using our automatic testing service Test My Code.
🌐
Py4j
py4j.org
Welcome to Py4J — Py4J
Py4J enables Python programs running in a Python interpreter to dynamically access Java objects in a Java Virtual Machine. Methods are called as if the Java objects resided in the Python interpreter and Java collections can be accessed through standard Python collection methods.
🌐
Coursera
coursera.org › coursera articles › computer science and engineering › web and app development › python vs. java: which should i learn?
Python vs. Java: Which Should I Learn? | Coursera
September 12, 2025 - According to Statista, Java was the most popular programming language worldwide in 2024 [1]. Several factors are driving Java's continued popularity, primarily its platform independence and relative ease of learning. Since its release, Java has become one of the most popular languages among web developers and other coding professionals. It's a general-purpose, object-oriented language. Unlike Python, Java is a compiled language, which is one of the reasons that it’s your faster option.
🌐
codecentric
codecentric.de › en › knowledge-hub › blog › java-classes-python
How to use Java classes in Python
November 15, 2021 - One can think about it, in a simplified way, like calling functions from dynamic libraries (experienced Pythonistas may find a comparison to the module ctypes helpful.) But JPype does this in a very comfortable way and automatically maps Java classes on Python classes.
🌐
Python Tutor
pythontutor.com › java.html
Visualize Java Code - Java Visualizer, Tutor, and Debugger with AI Help
Java visualizer, visual debugger, and AI tutor - the only tool that lets you visually debug your Java code step-by-step (also debug Python, JavaScript, C, and C++ code)
🌐
Runestone Academy
runestone.academy › ns › books › published › java4python › index.html
Welcome to Java for Python Programmers — Java for Python Programmers
Instructors Guide · About Runestone · Report A Problem · This Chapter · Contents: Java for Python Programmers · Preface · Introduction · Why Learn another programming Language? Lets look at a Java Program · Java Data Types · Conditionals · Loops and Iteration ·
🌐
Raygun
raygun.com › blog › java-vs-python
Java vs Python: Code examples and comparison · Raygun Blog
November 30, 2022 - As two of the most popular and practical languages out there, should you choose Java or Python for your next project? Is one of these languages a clear-cut better option? The answer is a long one. According to GitHub’s annual Octoverse report, Python has now climbed to the second most popular language in usage, pushing Java down to third place.
🌐
Great Learning
mygreatlearning.com › academy › learn-for-free › courses › python-fundamentals-for-beginners
Free Python Course for Beginners with Certificate [2026]
October 22, 2024 - How does python compare to other programming languages? Python is often considered more user-friendly and easier to read compared to languages like Java or C++. Its syntax is simpler and it's versatile across different fields.
Rating: 4.5 ​ - ​ 41.2K votes