JPype is an alternative to Jython that I made some good experience with. If it is not enough to call the java program and work with the output (it's hard to tell from your question), then JPype can be used to (more or less) transparently work with Java object in Python code.

I works by starting a JVM and handing requests to said JVM.

Answer from kutschkem on Stack Overflow
🌐
Stack Overflow
stackoverflow.com › questions › 27489109 › call-java-class-from-a-jar-file-in-python-easily-without-another-complicated-pro
Call java class from a jar file in python easily without another complicated program like Py4j - Stack Overflow
May 24, 2017 - Alternatively, Py4j and JPype appear to be libraries designed to allow interface with Java from CPython. ... A link which is a relevant reference to topic in hand is - link. ... Sign up to request clarification or add additional context in comments. ... This example just registers the jar file to the sys path.
🌐
Py4j
py4j.org
Welcome to Py4J — Py4J
Here is a brief example of what you can do with Py4J. The following Python program creates a java.util.Random instance from a JVM and calls some of its methods. It also accesses a custom Java class, AdditionApplication to add the generated numbers.
🌐
Manmustbecool
manmustbecool.github.io › MyWiki › Wiki › Python › python_java.html
Call Java from Python
And in windows using ‘;’ instead of ‘:’ (e.g. xxx/py4j0.10.5.jar;. AdditionApplication) ... from py4j.java_gateway import JavaGateway gateway = JavaGateway() # connect to the JVM random = gateway.jvm.java.util.Random() # create a java.util.Random instance number1 = random.nextInt(10) # call the Random.nextInt method print(number1) AdditionApplication addition_app = new gateway.jvm.AdditionApplication() # get the AdditionApplication instance value = addition_app.addition(4, 5)) # call the addition method print(value)
🌐
Readthedocs
jpy.readthedocs.io › en › latest › intro.html
Introduction — jpy 0.9.0 documentation
Java programs with jpy.jar on the classpath can import Python modules, access module attributes such as class types and variables, and call any callable objects such as module-level functions, class constructors, as well as static and instance class methods.
🌐
Data Science Learner
datasciencelearner.com › python › how-to-call-jar-file-using-python
How to Call Jar File Using Python? - Python Tutorial Data Science Learner
October 27, 2022 - This article " How to call jar file using Python " will brief you on two different ways in Python to call jar externally (os.system and subprocess.call) .
🌐
Python Software Foundation
wiki.python.org › jython › LearningJython
Jython Course Outline - Python Wiki
You will need to describe the signature of methods in order to make them callable from Java (in addition to Jython). What jythonc does -- jythonc translates .py files into .java source code files, then compiles these to .class files. ... Compile Jython (.py) to Java class files (.class).
🌐
Better Programming
betterprogramming.pub › accessing-java-classes-in-python-using-pyjnius-6122bcaad49a
Accessing Java Classes in Python Using Pyjnius | by Eldad Uzman | Better Programming
March 8, 2022 - Now, in our Python code, we should add the jar file to our Java classpath as shown below: First, we concluded where the jar file is at, then we added it to the Java classpath using jnius_config.set_classpath. Now our main section does the exact same thing our main method in Java did. It instantiated a list of integers from ...
Find elsewhere
🌐
LinuxTut
linuxtut.com › en › 9add34871a43c4181af7
[JAVA] Import classes in jar files directly from Python scripts
May 25, 2013 - Jython is a standard module and does not support SQLite, so a JDBC driver is required, If you can read the JDBC driver jar file directly from the Python script, You can use Java classes and SQLite from Python just by throwing in the files you need. import.sys sys.path.append("/path/to/hoge...
🌐
Liacs
rsewiki.liacs.nl › calling_java_from_python
Calling Java from Python [LIACS Wiki]
April 1, 2021 - This approach allows direct memory access between the two machines, implementation of Java interfaces in Python, and even use of Java threading. ... # Boiler plate stuff to start the module import jpype import jpype.imports from jpype.types import * # Launch the JVM jpype.startJVM(classpath=['jars/database.jar']) # import the Java modules from com.paying.customer import Database db = Database("our_records") with db.connect() as c: c.runQuery() while c.hasRecords(): recor...
🌐
Blogger
sujitpal.blogspot.com › 2006 › 10 › using-jython-to-call-java.html
Salmon Run: Using Jython to call Java
October 21, 2006 - Jython itself is a shell script and calls the org.python.util.jython class, so these parameters can be passed into the Java invocation in the jython shell script, although this does not seem to be very clean. Running the class through Jython also seems a little slower than running it through a Shell Script, but I haven't done any benchmarks to say this conclusively. ... Alex Kochnev said... Sujit, have you tested the code that you have on the blog ? In my experience, adding jar files to sys.path at runtime does not make the classes loadable - you either have to add the jars to the classpath before starting the app, or you have to work with loadSets to make the jar load..
🌐
Quora
quora.com › Is-it-possible-to-run-a-third-party-Java-library-in-Python
Is it possible to run a third-party Java library in Python? - Quora
Answer (1 of 3): Yes, by using a bridge. Py4J seems to be an up-to-date open source one: Welcome to Py4J - Py4J Got the hint from StackOverflow Calling Java from Python . Have used something similar myself also ages ago. Example: [code]>>> from py4j.java_gateway import JavaGateway # connect ...
🌐
GeeksforGeeks
geeksforgeeks.org › java › integrating-java-with-python
Integrating Java with Python - GeeksforGeeks
July 23, 2025 - For example, if we are writing our Java program in Eclipse, we need to include the jar file of py4j in the Java project. It is important to point out that py4j supports Java version 6 and above only. Let us examine a simple Java program HelloClass.java that has a method Message which returns Hello. To make the GFG accessible in a Python program, two things are required. First, the Python program should be able to access the Java Virtual Machine (JVM) running the Java program. This requires an instance of the GatewayServer class available in the library py4j that makes this communication possible.
🌐
Google Groups
groups.google.com › g › jep-project › c › _Anc4jLByGQ
How can I import a custom java class in python?
# importing the java.lang.Class objects from mypackage import car # instantiation x = Car(5) ... import mypackage.Car; import jep.Jep; public class FirstVersion { public static void main(String[] args) { try (Jep jep = new Jep()){ // this works Car c = new Car(5); System.out.println("Java: " + c.n); // this doesn't jep.runScript("/home/ubuntu/test.py"); } catch (Exception e) { System.out.println(e); } } } ... Java: 5 jep.JepException: <class 'ModuleNotFoundError'>: No module named 'mypackage' Process finished with exit code 0
🌐
codecentric AG
blog.codecentric.de › java-classes-python
How to use Java classes in Python - codecentric Blog
November 15, 2021 - First, during the training, where we will call it directly from Python. And later in production, where we will call it from our Java program to give the trained net a basis for making a decision. Enter JPype ! The import of a Java class — without any changes to the Java sources — can be accomplished simply with the following code: 1import jpype 2import jpype.imports 3from jpype.types import * 4 5# launch the JVM 6jpype.startJVM(classpath=['../target/autosnake-1.0-SNAPSHOT.jar']) 7 8# import the Java module 9from me.schawe.autosnake import SnakeLogic 10 11# construct an object of the `SnakeLogic` class ...