node-java-connector
Version:
enables platform independent java support
47 lines (34 loc) • 1.15 kB
Markdown
# node-java-connector
[](https://badge.fury.io/js/node-java-connector)

This package helps with running JAR-Files from JavaScript.
If no Java is installed on the system, a openJDK version will be installed temporarily.
An example can be found at https://github.com/NLueg/node-java-connector-example.
## Getting Started
1. Install the package:
```sh
npm install node-java-connector
```
2. Define a file like `install.js` where you deal with installing the JRE with the following content:
```js
const njb = require("node-java-connector");
njb
.install()
.then((dir) => {
// do something with the directory
})
.catch((err) => {
console.log(err);
});
```
3. Add the script to your `package.json` that the JRE gets installed everytime when your package gets installed:
```json
{
...
"scripts": {
"install": "node install.js",
}
...
}
```
4. Use the `executeJar` method with the path to your JAR-file and optional arguments or `executeClassWithCP` for non-executable JARs.