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 jdk4pyVerified import paths — ran on the pinned version, not inferred.
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.
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.
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.
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.
Ensure the package is installed by running `pip install jdk4py` and that your virtual environment (if used) is active.
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.
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.