Registry / devops / jdk4py

jdk4py

JSON →
library25.0.2.1pypypi✓ verified 84d ago

jdk4py is a Python library that bundles a specific version of the Java Development Kit (JDK) within a Python package, providing convenient access to the Java runtime directly from Python environments. It is often used to simplify the deployment of Python applications that depend on Java Virtual Machine (JVM)-based components, such as data analytics platforms. The library's versioning scheme reflects the bundled JDK version (the first three numbers) and its own API version (the fourth number), with frequent releases that generally align with upstream JDK updates.

pip install jdk4py
INSTALL
IMPORT
SIG · JDK4PY
J
jdk4py
devopspythonv25.0.2.1
Install
3.5s avg
Import
60ms
Disk
64MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v11.0.7.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.033s · 19.2MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 3.5s · import 0.088s · 122MB
64MB installed
● package 64MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

JAVA
from jdk4py import JAVA
Provides the Path object for the Java executable within the bundled JDK.
JAVA_HOME
from jdk4py import JAVA_HOME
Provides the Path object for the root directory of the bundled JDK.
JAVA_VERSION
from jdk4py import JAVA_VERSION
Provides a tuple (major, minor, patch) of the bundled JDK version.

This quickstart demonstrates how to import and use the `JAVA`, `JAVA_HOME`, and `JAVA_VERSION` constants to interact with the bundled JDK, including executing a simple Java command using Python's `subprocess` module.

import subprocess from jdk4py import JAVA, JAVA_HOME, JAVA_VERSION print(f"JDK Home: {JAVA_HOME}") print(f"Java Executable: {JAVA}") print(f"JDK Version: {JAVA_VERSION}") # Example of running a Java command (e.g., getting version) try: result = subprocess.run( [JAVA, "-version"], capture_output=True, check=True, text=True ) # Java -version typically prints to stderr print("Java Version Output:\n", result.stderr.strip()) except subprocess.CalledProcessError as e: print(f"Error running Java command: {e.stderr}") except FileNotFoundError: print("Java executable not found. Is jdk4py installed correctly?")
Debug
Known issues
breakingJDK Version Mismatches: `jdk4py` bundles a specific JDK version. If your existing Java applications or other Python libraries require a different Java version or specific JVM features not present in the bundled JDK, direct execution of Java commands via `jdk4py.JAVA` might lead to compatibility errors or unexpected behavior.
fix
Manually verify the required Java version for your dependent applications. If a different JDK is needed, consider managing it externally or using a tool like `pyenv` or `conda` to create isolated environments with specific `jdk4py` versions that bundle the appropriate JDK.
affects: All
gotcha`JAVA_HOME` Environment Variable Conflicts: `jdk4py` exposes `JAVA_HOME` and `JAVA` path variables programmatically. Relying on a globally set `JAVA_HOME` for system-wide Java installations might conflict with the `jdk4py`-managed path when executing Java applications through Python, leading to unexpected JVM launches or classpath issues.
fix
When using `jdk4py`, prefer using `jdk4py.JAVA` or `jdk4py.JAVA_HOME` directly in your Python code for launching Java processes to ensure the correct bundled JDK is used. Avoid mixing with externally managed `JAVA_HOME` environment variables in the same execution context.
affects: All
gotchaGPLv2 Licensing Implications: The `jdk4py` library is licensed under GNU General Public License v2 (GPLv2). This open-source license can have implications for redistribution or linking in proprietary applications.
fix
Review the GPLv2 license to understand its terms and conditions, especially if you plan to distribute applications that embed or link with `jdk4py`. Consult legal counsel if unsure about compliance.
affects: All
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'jdk4py'
The `jdk4py` package is not installed in the current Python environment or the environment is not activated.
fix
Ensure the package is installed by running `pip install jdk4py` and that your virtual environment (if used) is active.
FileNotFoundError: [Errno 2] No such file or directory: '/path/to/venv/lib/pythonX.Y/site-packages/jdk4py/java-runtime/bin/java'
The `java` executable within the `jdk4py` package could not be found. This might happen due to an incomplete installation, corruption, or if the path derived from `jdk4py.JAVA` is incorrect for the current system/installation.
fix
Try reinstalling `jdk4py` (`pip uninstall jdk4py && pip install jdk4py`). Verify the `jdk4py.JAVA` path directly in a Python interpreter to see if it points to a valid executable.
java.lang.UnsupportedClassVersionError: YourClass has been compiled by a more recent version of the Java Runtime (class file version XX.0), this version of the Java Runtime only recognizes class file versions up to YY.0
The Java application you are trying to run was compiled with a newer JDK than the one bundled with your `jdk4py` version, or vice-versa.
fix
Either recompile your Java application with an older JDK version compatible with `jdk4py`'s bundled JDK, or update `jdk4py` to a version that bundles a sufficiently new JDK. Ensure the major version of the bundled JDK matches the major version of the JDK used to compile your Java code.
Upgrade
Version history
25.0.2.1latest on PyPI · released Apr 23, 2026
Audit
Dependencies
pythonrequiredRequired Python version for installation.
Agent activity
10 hits · last 30 days
node
10
Resources
jdk4py — pip install jdk4py · libregistry