install-jdk allows you to easily install latest Java OpenJDK version. Supports OpenJDK builds from Adoptium (previously AdoptOpenJDK), Corretto, and Zulu. Simplify your Java development with the latest OpenJDK builds.
Project description
install-jdk
The install-jdk
library is a Python package that simplifies the process of installing OpenJDK on Windows, macOS, Linux and other supported operating systems, saving time and effort. install-jdk
is a useful tool for users, developers, and system administrators who need to set up Java development environment or runtime in an automated and repeatedable fashion.
install-jdk
has no third-party dependencies and depends solely on the standard libraries found in Python3. This means that you can easily install and use the library without having to install any additional dependencies.
install-jdk
aims to provide as many options as possible to install an OpenJDK Java version across a wide array of operating systems and architectures. Please see each vendors OpenJDK documentation to see what operating systems and architectures they support.
Supported OpenJDK Build Vendors
OpenJDK Build | Status | Vendor Tags | Vendor Documentation | install-jdk Documentation |
Source Code |
---|---|---|---|---|---|
Adoptium (default) | Implemented | Adoptium, Temurin, AdoptOpenJDK, eclipse | Adoptium | Adoptium Build Client docs | Adoptium Build Client src |
Corretto | Implemented | Corretto, Amazon, AWS | Corretto | Corretto Build Client docs | Corretto Build Client src |
Microsoft | Planning | Microsoft | ...coming soon | ||
Azul | Implemented | Azul, Zulu | Azul Zulu | ...coming soon | Zulu Build Client src |
install-jdk will do its best to detect the operating system and architecture that it is running on. Currently is able to detect:
-
Operating Systems
- Windows
- Linux
- MacOS
- AIX
-
Architecture
- arm
- aarch64
- ppc64
- x64
- x86
Installation
To install the install-jdk library, simply run the following command:
pip install install-jdk
Usage
To use the install-jdk
library, import it into your Python code:
import jdk
The library provides an install
function, which takes the following parameters:
version
- The major version of the Java OpenJDK build to install (e.g. 8, 11, 17, etc.).operating_system
- The target operating system. If not specified, will use the user's detected operating system if possible.arch
- The target architecure. If not specified, will use the user's detected architecture if possible.impl
- The Java implementation to use. Currently only supportsHOTSPOT
and dependent on the OpenJDK Build Vendor.jre
- A boolean value indicating that the Java Runtime Environment should be installed. Defaults to false, which will install the Java Development Kit.path
- The location to install the downloaded OpenJDK build. If not specified, will install into$HOME/.jdk/<VERSION>
for the Java Development Kit and$HOME/.jre/<VERSION>
for the Java Runtime Environment.vendor
- The vendor to download the OpenJDK build from. If not specified, defaults to Adoptium. This is a named argument so must be provided likevendor='Corretto'
. Please see the list of Supported OpenJDK Build Vendors
Here are some example code snippet:
jdk.install('11')
# Platform dependent install of Java JDK 11 into $HOME/.jdk/<VERSION>
jdk.install('11', jre=True)
# Platform dependent install of Java JRE 11 into $HOME/.jre/<VERSION>
jdk.install('17', vendor='Corretto')
# Installs a Corretto build of Java 17 JDK. Defualt vendor is Adoptium
jdk.install('17', vendor='Corretto', path='/usr/local/jdk')
# Installs a Corretto build of Java 17 JDK into /usr/local/jdk
The library also has a get_download_url
function that returns the URL for the given version, it takes the following parameters:
version
- The major version of the Java OpenJDK build to install (e.g. 8, 11, 17, etc.).operating_system
- The target operating system. If not specified, will use the user's detected operating system if possible.arch
- The target architecure. If not specified, will use the user's detected architecture if possible.impl
- The Java implementation to use. Currently only supportsHOTSPOT
and dependent on the OpenJDK Build Vendor.jre
- A boolean value indicating that the Java Runtime Environment should be installed. Defaults to false, which will install the Java Development Kit.vendor
- The vendor to download the OpenJDK build from. If not specified, defaults to Adoptium. This is a named argument so must be provided likevendor='Corretto'
. Please see the list of Supported OpenJDK Build Vendors
Here are some example code snippets:
from jdk.enums import OperatingSystem, Architecture
download_url = jdk.get_download_url('17', jre=True)
print(download_url)
# Obtains the platform dependent JRE download url
download_url = jdk.get_download_url('17', operating_system=OperatingSystem.LINUX, arch=Architecure.AARCH64, vendor='Corretto')
print(download_url)
# Obtains OpenJDK 17 from Corretto for Linux running on aarch64
The library has a download
function that will download the requested version and returns back the path to where it was downloaded. This function does not currently support overriding the default download path which is the operating systems specific TMP directory. It takes the following parameters.
download_url
- The URL to the file to be downloaded. Defaults to None.-
version
- Required whendownload_version
is None and must be provided as a named parameter. The major version of the Java OpenJDK build to install (e.g. 8, 11, 17, etc.).
-
operating_system
- Must be provided as a named parameter. The target operating system. If not specified, will use the user's detected operating system if possible.arch
- Must be provided as a named parameter. The target architecure. If not specified, will use the user's detected architecture if possible.impl
- Must be provided as a named parameter. The Java implementation to use. Currently only supportsHOTSPOT
and dependent on the OpenJDK Build Vendor.jre
- Must be provided as a named parameter. A boolean value indicating that the Java Runtime Environment should be installed. Defaults to false, which will install the Java Development Kit.vendor
- The vendor to download the OpenJDK build from. If not specified, defaults to Adoptium. This is a named argument so must be provided likevendor='Corretto'
. Please see the list of Supported OpenJDK Build Vendors
Here are some example code snippets:
from jdk.enums import OperatingSystem, Architecture
download_file = jdk.download('https://api.adoptium.net/v3/binary/latest/17/ga/windows/x64/jdk/hotspot/normal/eclipse')
print(download_file)
# Downloads the requested file and returns back the TMP locations it was stored in.
download_file = jdk.download(version='17', operating_system=OperatingSystem.LINUX, arch=Architecure.AARCH64, vendor='Corretto')
print(download_file)
# Downloads the a Linux aarch64 build of Java 17 from Corretto and returns back the TMP location it was stored in.
The library also provided two helper properties that can be used to see what it detected as the user's operating system and architecture.
print(jdk.OS)
print(jdk.ARCH)
Credits
The install-jdk library uses OpenJDK builds, and is created and maintained by jyksnw.
This was originally a port of the GitHub Action installjdk
but has morphed into something much more.
Vendor Credits
License
The install-jdk
library is open-source and is distributed under the MIT license. See the LICENSE file for more information.
Contribution
See CONTRIBUTING
Security contact information
To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.
Sponsor This Project
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file install_jdk-1.1.0.tar.gz
.
File metadata
- Download URL: install_jdk-1.1.0.tar.gz
- Upload date:
- Size: 15.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2bfd53caf660e4916df0215a5715519dcb9547fa2a5f07421fd97a8046851eaa |
|
MD5 | e10db7bd8151ba2cfe42f63ef1269fcc |
|
BLAKE2b-256 | cf67502a753533e9b4deb691f3f7ba6303682494f2d8ee651d6253cd78045b66 |
File details
Details for the file install_jdk-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: install_jdk-1.1.0-py3-none-any.whl
- Upload date:
- Size: 15.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b63f0fcd63f7abab3443d4120ba92716397753b8a8ea3c85762a629925a9936e |
|
MD5 | caacdff5131408ac47f29c8e57b0fd4a |
|
BLAKE2b-256 | 7e5eaf84054b0ff9f9fbe49a7079d46ba8b4ee7ab6192a0310d4bd2c91254626 |