A JDK shipped in a Python package.
pip install jdk4pyor
uv add jdk4pyThe jdk4py command runs a tool of the bundled JDK, such as java, keytool, or jcmd.
With uvx, it runs without installing jdk4py first:
uvx jdk4py java -version>>> from jdk4py import JAVA, JAVA_HOME, JAVA_VERSION
>>> JAVA_HOME
PosixPath('/Users/johndoe/dev/jdk4py/jdk4py/java-runtime')
>>> JAVA
PosixPath('/Users/johndoe/dev/jdk4py/jdk4py/java-runtime/bin/java')
>>> JAVA_VERSION
(25, 0, 5)
>>> from subprocess import run
>>> some_java_options = ["-Xmx16G", "-Xms2G"]
>>> run(
... [JAVA, *some_java_options, "-jar", "HelloWorld.jar"],
... capture_output=True,
... check=True,
... text=True,
... ).stdout.strip()
'Hello, World'jdk4py's version contains 4 numbers:
- The first 3 numbers are the first 3 numbers of the bundled JDK version.
JAVA_VERSIONholds them. - The fourth number starts at 0 and goes up by 1 with each release that keeps the first 3, for instance to bundle a JDK patch or to change the library.