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
🌐
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 ...
🌐
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."...
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.
🌐
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....
🌐
Sololearn
sololearn.com › en › Discuss › 1621770 › how-do-i-integrate-python-into-a-java-program
How do i integrate python into a java program. | Sololearn: Learn to code for FREE!
I developed an application with Java. I now intend to add a certain functionality which will pick data from a camera and send it to the app for analysis. the camera will