Skip to content
/ java-find Public

NPM package to find and list java installations, and their metadata.

License

Notifications You must be signed in to change notification settings

RX14/java-find

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

java-find

Node module for listing java installations, and finding their metadata.

Installation

npm install java-find --save

Usage

Example:

var javaFind = require("java-find");
var child_process = require("child_process");

javaFind.getJavas().then(javas => {
    javas
        .filter(java => java.arch == 'x64')
        .forEach(java => {
            child_process.execFile(java.path, ["-jar", "MyJar.jar"]);
        });
});

Calling gatJavas() will return a promise of an array of java version objects.

Java version objects looks like this:

{
    path: "/usr/bin/java",
    arch: "x86", // or x64
    version: { // 1.8.0_74 (Java 8)
        major: 1,
        minor: 8,
        patch: 0,
        update: 74
    }
}

You can also use the setDebug method to direct debug logging:

javaFind.setDebug(debug => {
    console.log(debug);
})