{"id":8234,"library":"install-jdk","title":"install-jdk","description":"install-jdk is a Python library that simplifies the process of installing OpenJDK distributions. It supports popular OpenJDK builds from Adoptium (formerly AdoptOpenJDK), Amazon Corretto, and Zulu, allowing developers to easily manage Java environments. The current version is 1.1.0, and it maintains a moderate release cadence with updates for dependencies and minor features.","status":"active","version":"1.1.0","language":"en","source_language":"en","source_url":"https://github.com/jyksnw/install-jdk","tags":["java","jdk","openjdk","environment","tooling","jvm"],"install":[{"cmd":"pip install install-jdk","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"jdk","correct":"import jdk"}],"quickstart":{"code":"import jdk\nimport os\n\n# Install the latest OpenJDK 17 from Adoptium to a temporary directory\n# This makes it runnable without affecting user's home directory\ninstall_path = jdk.install(\n    '17',\n    jvm_impl='adoptium',\n    install_dir=os.environ.get('JDK_INSTALL_DIR', '/tmp/jdk_install_cache')\n)\n\nprint(f\"OpenJDK 17 installed at: {install_path}\")\n\n# You can then use this path to set JAVA_HOME or run Java commands\n# For example, to print the Java version:\n# import subprocess\n# java_bin = os.path.join(install_path, 'bin', 'java')\n# if os.path.exists(java_bin):\n#     try:\n#         result = subprocess.run([java_bin, '-version'], capture_output=True, text=True, check=True)\n#         print(result.stderr) # Java version typically prints to stderr\n#     except subprocess.CalledProcessError as e:\n#         print(f\"Error running Java: {e.stderr}\")\n","lang":"python","description":"This quickstart installs the latest OpenJDK 17 from Adoptium to a specified directory (defaulting to a temporary path to avoid permissions issues). It demonstrates the core `jdk.install()` function and prints the installation path. Users would typically use this `install_path` to configure their `JAVA_HOME` environment variable or invoke the Java executable directly."},"warnings":[{"fix":"After `jdk.install()` returns the `install_path`, manually set your `JAVA_HOME` environment variable to this path and add `$JAVA_HOME/bin` to your system's PATH. For example, `export JAVA_HOME=/path/to/installed/jdk`.","message":"install-jdk installs JDKs to a local cache directory (e.g., `~/.jdk` or a custom `install_dir`), but it does not automatically modify system-wide PATH or set `JAVA_HOME` for your operating system. You must manually configure these environment variables for applications to find the installed JDK.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure you are using a compatible Python version (3.6-3.9). It is recommended to use a virtual environment with the correct Python interpreter version for `install-jdk`.","message":"The library explicitly requires Python versions `>=3.6,<4.0`. Using Python 3.10 or newer will result in installation errors or unexpected runtime behavior.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Verify your internet connection. If you are behind a corporate proxy, ensure your Python environment's proxy settings (e.g., `HTTP_PROXY`, `HTTPS_PROXY` environment variables) are correctly configured.","message":"JDK installation requires active internet access to download binaries from remote servers. Network issues, firewalls, or proxy configurations can cause installation failures.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always specify the `jvm_impl` argument, e.g., `jdk.install('11', jvm_impl='corretto')`, to ensure you get the desired JDK distribution.","message":"When calling `jdk.install()`, if you omit `jvm_impl`, it defaults to 'adoptium'. If you expect a different vendor (e.g., Corretto or Zulu), you must explicitly specify it.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Run `pip install install-jdk` in your active virtual environment or global Python installation.","cause":"The `install-jdk` package was not installed or is not accessible in the current Python environment.","error":"ModuleNotFoundError: No module named 'jdk'"},{"fix":"Double-check the exact version string (e.g., use '8' instead of '1.8' for Java 8, or '17' for Java 17). Verify the `jvm_impl` (e.g., 'adoptium', 'corretto', 'zulu') and `jvm_variant` (e.g., 'hotspot', 'openjdk') are correct and supported.","cause":"The specified JDK version, JVM implementation, or variant combination could not be found or is not supported by the available providers. This can happen with very old, pre-release, or incorrect version strings.","error":"ValueError: Could not find a suitable JDK version for '1.8' (or similar for other versions/impls)"},{"fix":"Run the script with appropriate user permissions, or specify an `install_dir` where the user has write access, e.g., `jdk.install('17', install_impl='adoptium', install_dir='/tmp/my_jdks')`.","cause":"The user running `install-jdk` does not have write permissions to the default installation directory (usually `~/.jdk`) or a custom `install_dir` provided.","error":"PermissionError: [Errno 13] Permission denied: '/path/to/.jdk'"}]}