orjp - Python & Java Interop
Overview
orjp (Java & Python Interop) is a Python package that allows you to call static Java methods directly from Python code, making Java interoperability seamless and intuitive.
Features
- Call static Java methods as if they were Python functions
- Automatically converts Java source files to reflection-friendly classes
- Support for all Java primitive types (int, double, float, boolean, long, String)
- Reflection-based approach that doesn't require JNI or external JVM libraries
Quick Start
1. Installation
pip install orjp
2. Import and Use
from orjp import subject
# Call static methods like Python functions
result = subject.test() # Calls into Java
result = subject.greet("world", 3) # Calls into the matching Java overload
# Or use the call API
from orjp import call
call("subject.java", "test")
3. Creating Java Source Files
Create a .java file in the orjp/jvm/ directory:
public class Subject {
public static String greet(String name, int times) {
return String.format("Hello %s (x%s)", name, times);
}
public static void test() {
System.out.println("Test method called");
}
}
The package will automatically convert this to a reflection-friendly class available in Python.
Implementation Details
The package works by:
- Accepting Java source code as input
- Parsing and extracting static method signatures using regex
- Generating reflection-compatible wrapper classes that use Java's reflection APIs
- Creating Python classes that map directly to these generated Java classes
This approach eliminates the need for JNI (Java Native Interface) and complex JVM native libraries, while providing a clean, Pythonic interface for Java interop.
Advantages
- No JNI required - Uses pure Java reflection
- Clean API - Java methods look and behave like Python functions
- Type-safe - Maintains Java type checking while providing Python-like syntax
- Simple setup - No external JVM installation needed
- Automatic conversion - Java files are transformed transparently
Supported Types
int,double,float,boolean,long- converted to appropriate Java typesString- passed through directly- Other types - supported through reflection
Note on Licensing
This package is intended for development and demonstration purposes. For commercial use or production environments, consider the associated licensing terms.
Project Links
Metadata
Release files for orjp 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| orjp-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for orjp-0.1.1-py3-none-any.whl |
Release files / orjp-0.1.1-py3-none-any.whl
| Download URL | orjp-0.1.1-py3-none-any.whl |
|---|---|
| Size | 8.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c14cf508763dd98b0868fb511eb8a2fa5090f283ef0f4eaf99724102dd5bb5c9
|
|
BLAKE2b-256 checksum How to use checksums |
2fa3a004f22782f5a4607c046ad91c86b2653f569761b6e502765e932945a8a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Security for orjp 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.