# njre

> Easily install and use JRE from a Node application.

Latest version **3.0.0** (published 2026-08-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install njre
pnpm add njre
yarn add njre
bun add njre
```

## Health

**Score 60/100 (C)** — status: active.

Positive: no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2026-08-09 |
| First published | 2019-05-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=18 |
| Dependencies | 2 |
| Unpacked size | 22.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 13 |
| Author | RaphaÃ«l ThÃ©riault |
| Maintainers | nvuillam, raftario |
| Keywords | jre, java, javaw, jdk, openjdk, adoptopenjdk, adoptium |

## Links

- npm: https://www.npmjs.com/package/njre
- Repository: https://github.com/nvuillam/njre
- Homepage: https://github.com/raftario/njre
- Issues: https://github.com/raftario/njre/issues
- npm.io page: https://npm.io/package/njre

## Dependencies (2)

- [tar](https://npm.io/package/tar.md) ^7.5.16
- [yauzl](https://npm.io/package/yauzl.md) ^3.1.3

## Recent versions

- 3.0.0 (latest) — 2026-08-09
- 2.0.0 — 2026-06-29
- 1.5.5 — 2026-06-28
- 1.5.4 — 2026-03-29
- 1.5.3 — 2026-02-28
- 1.5.2 — 2026-01-22
- 1.5.0 — 2025-12-03
- 1.4.2 — 2025-02-23
- 1.4.0 — 2024-08-29
- 1.3.0 — 2024-08-20
- 1.2.2 — 2024-07-16
- 1.2.1 — 2024-05-08
- 1.2.0 — 2024-05-08
- 1.1.0 — 2023-11-26
- 1.0.0 — 2023-09-19
- … 5 more at https://npm.io/package/njre/versions

## README

# njre

![npm](https://img.shields.io/npm/v/njre.svg)
[![Downloads/week](https://img.shields.io/npm/dw/njre.svg)](https://npmjs.org/package/njre)<!-- gh-dependents-info-used-by-start -->
[![Generated by github-dependents-info](https://img.shields.io/static/v1?label=Used%20by&message=1014&color=informational&logo=slickpic)](https://github.com/nvuillam/njre/blob/main/docs/github-dependents-info.md)<!-- gh-dependents-info-used-by-end -->
[![MegaLinter](https://github.com/nvuillam/njre/workflows/MegaLinter/badge.svg?branch=master)](https://github.com/nvuillam/njre/actions?query=workflow%3AMegaLinter+branch%3Amain)
[![GitHub stars](https://img.shields.io/github/stars/nvuillam/njre?cacheSeconds=3600)](https://github.com/nvuillam/njre/stargazers/)
[![GitHub contributors](https://img.shields.io/github/contributors/nvuillam/njre.svg)](https://github.com/nvuillam/njre/graphs/contributors/)
[![GitHub Sponsors](https://img.shields.io/github/sponsors/nvuillam)](https://github.com/sponsors/nvuillam)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)

Easily install and use JRE (or JDK) from a Node application. Binaries are downloaded from [Eclipse Temurin / Adoptium](https://adoptium.net/), 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

```bash
npm install njre
```

## Usage

```js
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.

| Param                    | Type     | Default                             | Description                                                                                                                                                |
|--------------------------|----------|-------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `[version]`              | `number` | `8`                                 | Java major version (e.g. `8`/`11`/`17`/`21`). On macOS the minimum is `11`.                                                                                |
| `[options.os]`           | `string` | current OS                          | Operating System (`windows`/`mac`/`linux`/`solaris`/`aix`)                                                                                                 |
| `[options.arch]`         | `string` | current CPU                         | Architecture (`x64`/`x32`/`ppc64`/`s390x`/`ppc64le`/`aarch64`/`sparcv9`)                                                                                   |
| `[options.openjdk_impl]` | `string` | `hotspot`                           | OpenJDK Implementation (`hotspot`)                                                                                                                         |
| `[options.release]`      | `string` | `latest`                            | Exact release name (e.g. `jdk-21+34-ea-beta`), or `latest` for the latest GA build of `version`                                                            |
| `[options.type]`         | `string` | `jre`                               | Binary Type (`jre`/`jdk`)                                                                                                                                  |
| `[options.heap_size]`    | `string` | `normal`                            | Heap Size (`normal`/`large`)                                                                                                                               |
| `[options.vendor]`       | `string` | `eclipse`                           | JRE/JDK vendor (`eclipse`/`adoptopenjdk`). Both resolve to api.adoptium.net (Eclipse Temurin); the deprecated api.adoptopenjdk.net host is no longer used. |
| `[options.installPath]`  | `string` | main 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.

```bash
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](CLAUDE.md) for development setup, project layout and testing instructions.

---
_Source: https://npm.io/package/njre · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
