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.
- Install the package:
npm install node-java-connector- Define a file like
install.jswhere you deal with installing the JRE with the following content:
constnjb=require("node-java-connector");njb.install().then((dir)=>{// do something with the directory}).catch((err)=>{console.log(err);});- Add the script to your
package.jsonthat the JRE gets installed everytime when your package gets installed:
{
..."scripts": {
"install": "node install.js",
}
...
}- Use the
executeJarmethod with the path to your JAR-file and optional arguments orexecuteClassWithCPfor non-executable JARs.