Skip to content
activeviamPublic

About

A JDK shipped in a Python package

Topics

Resources

Stars

33 stars

Watchers

4 watching

Forks

Repository files navigation

jdk4py

PyPI Python License

A JDK shipped in a Python package.

Install

pip install jdk4py

or

uv add jdk4py

Usage

Command line

The 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

Python API

>>> 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'

Versioning

jdk4py's version contains 4 numbers:

  • The first 3 numbers correspond to the JDK version.
  • The fourth number is the library API version.

About

A JDK shipped in a Python package

Topics

Resources

Stars

33 stars

Watchers

4 watching

Forks

Used by

Contributors

Languages