You can keep things in separate projects without having to copy the .class files to the Python project provided that you make that project a PyDev project and add the place that contains the .class files (i.e.: bin folder) as a source folder in the PyDev configuration (and reference that project from your Python project).

Take a look at "Project reference for Jython users" (in the end of http://pydev.org/manual_101_project_conf2.html).

I think you could also do what you asked in your question: create a java project, set it as a PyDev project too (right click that project > pydev > set as pydev project) and configure the PyDev project properties setting the PYTHONPATH to the place where you have your Python files and add another entry to the bin folder (i.e.: where the .class files exist). Not sure if it'd be better to keep those as 2 separated projects though.

Answer from Fabio Zadrozny on Stack Overflow
๐ŸŒ
YouTube
youtube.com โ€บ watch
Integrating Python and Java in Eclipse2 - YouTube
Python (specifically CPython) is heavily used in science, in part thanks to its fast powerful libraries such as numpy and scipy. It is still one of the best ...
Published ย  October 30, 2015
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ integrating-java-with-python
Integrating Java with Python - GeeksforGeeks
July 23, 2025 - It can be installed by executing ... example, if we are writing our Java program in Eclipse, we need to include the jar file of py4j in the Java project....
๐ŸŒ
Huihoo
docs.huihoo.com โ€บ eclipse โ€บ eclipsecon โ€บ europe2015 โ€บ Integrating-Python-and-Java-for-High-Throughput-Science-in-Eclipse.pdf pdf
Integrating Java and Python - Huihoo
๏‚กJava to Python ยท ๏‚งIn Java, code can access scripts in Python ยท ๏‚งWorkflows, Extending Eclipse with Python ยท 1. PyDev ยท ๏ƒ˜C Python ยท ๏ƒ˜Jython ยท ๏ƒ˜PyPy ยท ๏ƒ˜IronPython ยท ๏ƒ˜Cython ยท ๏ƒ˜IPython ยท 1. PyDev - Debug ยท 1. PyDev - Integration ยท 2. Jython ยท ๏’Java implementation of Python ยท
๐ŸŒ
Readthedocs
jython.readthedocs.io โ€บ en โ€บ latest โ€บ JythonAndJavaIntegration
Chapter 10: Jython and Java Integration โ€” Definitive Guide to Jython latest documentation
This chapter will focus on integrating Java and Python, but it will take several different vantage points on the topic. You will learn several techniques to make use Jython code within your Java applications. Perhaps youโ€™d like to simplify your code a bit, this chapter will show you how to write certain portions of your code in Jython and others in Java so that you can make code as simple as possible.
๐ŸŒ
YouTube
youtube.com โ€บ eclipse foundation
Integrating Python and Java for High Throughput Science in Eclipse - YouTube
Python (specifically CPython) is heavily used in science, in part thanks to its fast powerful libraries such as numpy and scipy. It is still one of the best ...
Published ย  November 10, 2015
Views ย  5K
๐ŸŒ
Eclipse Foundation
eclipse.org โ€บ community โ€บ eclipse_newsletter โ€บ 2015 โ€บ january โ€บ article2.php
Integrating Python For High Throughput Science | The Eclipse Foundation
So this was the next problem that needed solving and gave rise to an in-house solution known as AnalysisRPC. AnalysisRPC is a Python-to-Java bridge that provides a generic way to call Python functions from Java as well as Java functions from Python.
๐ŸŒ
Pdxdev
python.pdxdev.com โ€บ questions โ€บ can-i-do-python-programming-from-java-eclipse-ide
Python Programming in Java Eclipse IDE?
This article explores the possibilities of using your familiar Java Eclipse IDE to write and execute Python code. Learn about plugins, setup, and practical examples. ...
Find elsewhere
๐ŸŒ
YouTube
youtube.com โ€บ next day video
Integrating Jython with Java - YouTube
Jim Baker, Shashank BharadwajJython provides a nearly seamless integration when using Javacode. Using Jython from Java is not nearly as seamless, at least no...
Published ย  March 20, 2013
Views ย  9K
๐ŸŒ
Learn IT University
learn-it-university.com โ€บ home โ€บ seamlessly integrate python into your java applications: a guide to calling python from java
Seamlessly Integrate Python into Your Java Applications: A Guide to Calling Python from Java - Learn IT University
July 21, 2024 - Integrating Python with Java can seem daunting at first, but with the right tools and setup, it becomes a manageable task. This article will guide you through the process of calling Python functions from Java using Jython, as well as other methods available in the Java ecosystem.
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 38228568 โ€บ how-to-switch-between-python-and-java-using-eclipse
How to switch between python and java using eclipse - Stack Overflow
July 6, 2016 - ... You need to switch to java environment in eclipse then only you would be able to import java project ! refer this : http://help.eclipse.org/luna/index.jsp?topic=/org.eclipse.platform.doc.user/tasks/tasks-9f.htm ...
๐ŸŒ
LinkedIn
linkedin.com โ€บ pulse โ€บ integrating-python-java-guide-developers-myexamcloud-7g5bc
Integrating Python and Java: A Guide for Developers
December 26, 2023 - Jython code can call Java libraries, ... in your Java project, you need to add the Jython JAR file to the project's classpath and then import the package "org.python.util.PythonInterpreter."...
๐ŸŒ
SAP Community
community.sap.com โ€บ t5 โ€บ technology-blog-posts-by-members โ€บ adding-a-python-plug-in-to-eclipse-ide โ€บ ba-p โ€บ 13787961
Adding a Python Plug in to Eclipse IDE - SAP Community
August 12, 2024 - Next you will see a Python perspective added in Eclipse ยท Next we will create a new project for Python, Right Click in Project area New --> Other ... Next we need to select the python installation path from your computer select new and then ...
Top answer
1 of 12
38

Why not use Jython? The only downside I can immediately think of is if your library uses CPython native extensions.

EDIT: If you can use Jython now but think you may have problems with a later version of the library, I suggest you try to isolate the library from your app (e.g. some sort of adapter interface). Go with the simplest thing that works for the moment, then consider JNI/CPython/etc if and when you ever need to. There's little to be gained by going the (painful) JNI route unless you really have to.

2 of 12
21

Frankly most ways to somehow run Python directly from within JVM don't work. They are either not-quite-compatible (new release of your third party library can use python 2.6 features and will not work with Jython 2.5) or hacky (it will break with cryptic JVM stacktrace not really leading to solution).

My preferred way to integrate the two would use RPC. XML RPC is not a bad choice here, if you have moderate amounts of data. It is pretty well supported โ€” Python has it in its standard library. Java libraries are also easy to find. Now depending on your setup either Java or Python part would be a server accepting connection from other language.

A less popular but worth considering alternative way to do RPCs is Google protobuffers, which have 2/3 of support for nice rpc. You just need to provide your transport layer. Not that much work and the convenience of writing is reasonable.

Another option is to write a C wrapper around that pieces of Python functionality that you need to expose to Java and use it via JVM native plugins. You can ease the pain by going with SWIG SWIG.

Essentially in your case it works like that:

  1. Create a SWIG interface for all method calls from Java to C++.
  2. Create C/C++ code that will receive your calls and internally call python interpreter with right params.
  3. Convert response you get from python and send it via swig back to your Java code.

This solution is fairly complex, a bit of an overkill in most cases. Still it is worth doing if you (for some reason) cannot afford RPCs. RPC still would be my preferred choice, though.

๐ŸŒ
Medium
medium.com โ€บ @chamlinid โ€บ integrate-java-and-python-code-bases-1c4819fe19da
Integrate Java and Python code bases | by Chamlini Dayathilake | Medium
February 14, 2025 - To do this, we can use the โ€œsysโ€ library in Python. The one thing you need to make sure of is that you need to be mindful of the order of the parameter values. As you see below, an indexing system is used to access the values that are received.
๐ŸŒ
Jython
jython.org
Home | Jython
import org.python.util.PythonInterpreter; public class JythonHelloWorld { public static void main(String[] args) { try(PythonInterpreter pyInterp = new PythonInterpreter()) { pyInterp.exec("print('Hello Python World!')"); } } } from java.lang import System # Java import print('Running on Java version: ' + System.getProperty('java.version')) print('Unix time from Java: ' + str(System.currentTimeMillis()))
๐ŸŒ
SSSgram
analyticsinsight.net โ€บ home โ€บ latest news โ€บ integrating python with java: a detailed guide
Integrating Python with Java: A Detailed Guide
October 11, 2023 - Developers may combine the benefits ... Java integration can be done in a variety of ways. Using Jython, a Python interpreter created in Java, is one well-liked technique....