- followToAdoptium()
The API will decide if it needs to redirect from api.adoptopenjdk.net to api.adoptium.net before finally redirecting to the binary. This function handles the initial redirection if needed, otherwise it just returns the location url for the binary.
- install([version], [options]) ⇒
Installs a JRE copy for the app
The API will decide if it needs to redirect from api.adoptopenjdk.net to api.adoptium.net before finally redirecting to the binary. This function handles the initial redirection if needed, otherwise it just returns the location url for the binary.
Installs a JRE copy for the app
Kind: global function
Returns: Promise - Resolves to the installation directory or rejects an error
Param | Type | Default | Description |
---|---|---|---|
[version] | number |
8 |
Java Version (8 /9 /10 /11 /12 ) |
[options] | object |
Installation Options | |
[options.os] | string |
Operating System (defaults to current) (windows /mac /linux /solaris /aix ) |
|
[options.arch] | string |
Architecture (defaults to current) (x64 /x32 /ppc64 /s390x /ppc64le /aarch64 /sparcv9 ) |
|
[options.openjdk_impl] | string |
"hotspot" |
OpenJDK Implementation (hotspot /openj9 ) |
[options.release] | string |
"latest" |
Release |
[options.type] | string |
"jre" |
Binary Type (jre /jdk ) |
[options.heap_size] | string |
Heap Size (normal /large ) |
|
[options.vendor] | string |
defaults to adoptopenjdk (adoptopenjdk /eclipse ) |
|
[options.installPath] | string |
Where to install java (default process.cwd()) |
Example
const njre = require('njre')
// Use default options
njre.install()
.then(dir => {
// Do stuff
})
.catch(err => {
// Handle the error
})
// or custom ones
njre.install(11, { os: 'aix', arch: 'ppc64', openjdk_impl: 'openj9' })
.then(dir => {
// Do stuff
})
.catch(err => {
// Handle the error
})
// or custom ones
njre.install(17, { os: 'aix', arch: 'amd64', openjdk_impl: 'openj9', installPath: "/home/tmp/java" })
.then(dir => {
// Do stuff
})
.catch(err => {
// Handle the error
})