skillfed

pyjnius

A Python library for accessing access Java classes as using the Java Native Interface (JNI).

pyjnius v1.7.0 295.3K downloads/30d#7,927 on PyPI1,482
Permissive license Active released

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 pyjnius

uv

uv add pyjnius

poetry

poetry add pyjnius

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseNatural Language :: EnglishOperating System :: AndroidOperating System :: MacOSOperating System :: Microsoft :: WindowsOperating System :: POSIX :: LinuxProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Application Frameworks

Tags

python java interop jnicall java from pythonjava native interface pythonpython android java bridgejni wrapper pythonjava class access pythonpython jvm integration
java-interopjni-bridgeandroid-kivy

More Application Frameworks packages