pyjnius
A Python library for accessing access Java classes as using the Java Native Interface (JNI).
What it is and what it does
PyJNIus is a Python library that bridges Python and Java by exposing Java classes and methods to Python code via the Java Native Interface (JNI). It lets you instantiate Java objects, call methods, access fields, and work with Java data types directly from Python—all without writing native C code yourself. The library is managed by the Kivy team and works on desktop (macOS, Linux, Windows) and mobile (Android) platforms.
You can use it two ways: with autoclass() for dynamic discovery of all Java class members, or by manually declaring JavaClass subclasses with specific methods and fields for finer control. It's commonly used in Kivy mobile apps to access Android hardware and in desktop applications that need to leverage existing Java libraries or interact with the JVM.
Use it for:
- Access Android hardware sensors and APIs from a Python mobile app built with Kivy.
- Call Java utility classes and data structures from Python without rewriting them.
- Integrate Python scripts with existing Java libraries or legacy Java codebases on desktop systems.
- Build cross-platform mobile apps where Python handles UI logic and Java handles platform-specific functionality.
- Prototype or automate Java applications by scripting them from Python.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
PyJNIus lets Python code call Java classes and methods directly using the Java Native Interface (JNI), enabling interoperability between Python and Java on desktop and mobile platforms.
Yes, if you need Python–Java interoperability. PyJNIus is actively maintained, MIT-licensed, widely used, has no known vulnerabilities, and ships pre-built wheels for modern Python versions. The main requirement is having a JDK installed and configured—a one-time setup cost. Install it if you're building a Kivy mobile app, integrating Python with Java libraries, or automating JVM-based systems.
Install
pyjnius on PyPI
pip
pip install pyjniusuv
uv add pyjniuspoetry
poetry add pyjniusInstalling pyjnius
Before you install
Medium install friction: the package ships pre-built wheels for Python 3.10, 3.11, 3.12, and 3.13 across macOS, Linux, Windows, and ARM platforms, but requires a Java Development Kit (JDK) to be installed and configured on your system. On Windows, JAVA_HOME must be set; on macOS and Linux it is usually auto-detected. The project is actively maintained with recent activity.
License in practice
PyJNIus is MIT licensed (permissive), allowing free use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects.
Quickstart
pip install pyjnius
from jnius import autoclass
Stack = autoclass('java.util.Stack')
stack = Stack()
stack.push('hello')
print(stack.pop())
A Java Development Kit (JDK) must be installed and JAVA_HOME configured on Windows; on macOS and Linux, JDK is typically auto-detected.
Verify before relying
- Whether pre-built wheels include JNI headers or if compilation from source requires additional build tools.
- Performance overhead of the Python–Java bridge for high-frequency method calls.
- Compatibility with alternative JVM implementations beyond standard OpenJDK.
Package facts
| License | not declared (permissive) |
| Python support | not specified |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 340 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 295,263/month — #7,927 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pyjnius-1.7.0-cp310-cp310-macosx_10_9_universal2.whl; pyjnius-1.7.0-cp310-cp310-macosx_10_9_x86_64.whl; pyjnius-1.7.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; pyjnius-1.7.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; pyjnius-1.7.0-cp310-cp310-win32.whl; pyjnius-1.7.0-cp310-cp310-win_amd64.whl; pyjnius-1.7.0-cp311-cp311-macosx_10_9_universal2.whl; pyjnius-1.7.0-cp311-cp311-macosx_10_9_x86_64.whl; pyjnius-1.7.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; pyjnius-1.7.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; pyjnius-1.7.0-cp311-cp311-win32.whl; pyjnius-1.7.0-cp311-cp311-win_amd64.whl; pyjnius-1.7.0-cp312-cp312-macosx_10_13_universal2.whl; pyjnius-1.7.0-cp312-cp312-macosx_10_13_x86_64.whl; pyjnius-1.7.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; pyjnius-1.7.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; pyjnius-1.7.0-cp312-cp312-win32.whl; pyjnius-1.7.0-cp312-cp312-win_amd64.whl; pyjnius-1.7.0-cp313-cp313-macosx_10_13_universal2.whl; pyjnius-1.7.0-cp313-cp313-macosx_10_13_x86_64.whl
Keywords: Java, JNI, Android
Tags
More Application Frameworks packages
FastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
textualTextual is a Python framework for building…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
mcpBuild and connect to Model Context Protocol…
permissive · top 1,000 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
KivyKivy is a Python framework for building…
permissive · top 15,000 on PyPI
jdk4pyBundles a JDK runtime into a Python package,…
copyleft · top 15,000 on PyPI
mutf8Encodes and decodes MUTF-8 (Modified UTF-8), a…
permissive · top 5,000 on PyPI
install-jdkAutomates the download and installation of…
permissive · top 15,000 on PyPI
jpype1JPype provides Python access to Java classes…
permissive · top 1,000 on PyPI
plyerPlyer provides a platform-independent Python…
permissive · top 15,000 on PyPI
asynckivyAsyncKivy replaces Kivy's callback-based event…
permissive · top 15,000 on PyPI
py4jPy4J enables Python programs to dynamically…
permissive · top 1,000 on PyPI
pyjksPyJKS loads and manipulates Java KeyStore…
permissive · top 5,000 on PyPI
allukaAlluka is a type-based dependency injection…
permissive · top 15,000 on PyPI