njre

August 9, 2026 · View on GitHub

npm Downloads/week Generated by github-dependents-info MegaLinter GitHub stars GitHub contributors GitHub Sponsors PRs Welcome

Easily install and use JRE (or JDK) from a Node application. Binaries are downloaded from Eclipse Temurin / Adoptium, verified against their SHA-256 checksum, and extracted locally.

  • Requires Node.js >= 18
  • Only 2 dependencies (tar and yauzl, for archive extraction) - everything else uses Node.js built-in modules

Installation

npm install njre

Usage

const njre = require("njre");

// Install the default JRE (Java 8, or Java 11 on macOS) next to the app
const dir = await njre.install();

// Or customize the version and options
const dir = await njre.install(21, { type: "jdk", installPath: "/opt/my-app" });

API

install([version], [options])Promise<string>

Downloads and extracts a JRE/JDK copy for the app. Resolves to the installation directory (a jre folder containing the extracted jdk-... distribution), or rejects with an error.

ParamTypeDefaultDescription
[version]number8Java major version (e.g. 8/11/17/21). On macOS the minimum is 11.
[options.os]stringcurrent OSOperating System (windows/mac/linux/solaris/aix)
[options.arch]stringcurrent CPUArchitecture (x64/x32/ppc64/s390x/ppc64le/aarch64/sparcv9)
[options.openjdk_impl]stringhotspotOpenJDK Implementation (hotspot)
[options.release]stringlatestExact release name (e.g. jdk-21+34-ea-beta), or latest for the latest GA build of version
[options.type]stringjreBinary Type (jre/jdk)
[options.heap_size]stringnormalHeap Size (normal/large)
[options.vendor]stringeclipseJRE/JDK vendor (eclipse/adoptopenjdk). Both resolve to api.adoptium.net (Eclipse Temurin); the deprecated api.adoptopenjdk.net host is no longer used.
[options.installPath]stringmain module path or process.cwd()File or directory path whose parent directory receives the jre folder. The parent directory must exist.

Proxy

If the HTTPS_PROXY (or HTTP_PROXY) environment variable is set (upper or lower case), njre downloads binaries through that proxy (HTTP CONNECT tunnel). Hosts listed in NO_PROXY (comma-separated, * wildcard supported) bypass it.

HTTPS_PROXY=http://proxy.mycompany.com:8080 node my-app.js

# With credentials (Basic auth, percent-encode special characters)
HTTPS_PROXY=http://user:p%40ssword@proxy.mycompany.com:8080 node my-app.js

Debug logs

Set NODE_DEBUG=njre to print debug logs (resolved download URL, proxy usage).

Contributing

See CLAUDE.md for development setup, project layout and testing instructions.