PyJNIus lets Python code use Java classes through the Java Native Interface. It can start a JVM in-process or attach to an existing one, including on Android.
Overview
PyJNIus is a Python library for reaching Java classes via JNI. It can spin up a new Java virtual machine inside your process or hook into a JVM that is already running, which matters on Android where Java is already present.
The Kivy team maintains PyJNIus, and it integrates with python-for-android builds. You can also use it outside the Kivy stack on desktop and mobile systems. Reflection helpers can discover methods and fields on Java types, or you can declare only the pieces you need.
On desktop you need a Java runtime; building from source needs a JDK. Windows installs may require setting a Java home environment variable so the library can find jvm.dll. Documentation covers installation, quickstart examples, Android-specific topics such as sensors and audio, and API details for exceptions, signatures, threads, and classpath options.
PyJNIus fits workflows where Python must drive Android APIs, Java libraries, or other JVM code without rewriting those pieces in Python.
Key features
- JNI access to Java classes from Python
- Start or attach to a JVM in-process
- Automatic class introspection via autoclass
- Manual declaration of Java methods and fields
- python-for-android integration
- Works independently of Kivy
- Android-focused usage examples
- Method signature inspection
Use cases
- Android app logic in Python with Java APIs
- Calling Java libraries from Python
- Kivy/python-for-android distributions
- Desktop automation with JVM libraries
- Inspecting Java method signatures from Python