0.5.1 • Published 8 months ago

jdk-utils v0.5.1

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

node-jdk-utils

A collection of Java related utils.

Installation

npm i jdk-utils

Usage

findJavaRuntime

Find Java runtime from all possible locations on your machine. Covering:

  • JAVA_HOME.
  • JDK-like paths from PATH.
  • SDKMAN installation location.
  • jabba installation location, i.e. ~/.jabba/jdk
  • ASDF installation location.
  • JDK installations managed by Gradle, e.g. ~/.gradle/jdk
  • Links specified in jEnv.
  • Homebrew installation:
    • macOS Intel: /usr/local
    • macOS Apple Silicon: /opt/homebrew
    • Linux: /home/linuxbrew/.linuxbrew
  • Platform-specific conventional installation location:
    • Linux: /usr/lib/jvm
    • macOS: /Library/Java/JavaVirtualMachines, ~/Library/Java/JavaVirtualMachines, output of java_home -V.
    • Windows: JDK-like folders under %ProgramFiles% and %LocalAppData%,

Note: If you want to skip scanning a certain source for better performance, you can specify skipFrom options when calling the API.

CLI

Below command lists all detected JDKs with details.

npx jdk-utils

callback-style

require("jdk-utils").findRuntimes().then(console.log)
/*
[{
    homedir: '/home/username/.sdkman/candidates/java/17.0.1-ms',
  }, {
    homedir: '/usr/lib/jvm/java-11-openjdk-amd64',
  },
...
]
*/

promise-style

import { findRuntimes } from "jdk-utils";
await findRuntimes({checkJavac: true, withVersion: true, withTags: true});
/*
[{
    homedir: '/home/yanzh/.sdkman/candidates/java/17.0.1-ms',
    hasJavac: true,
    isFromSDKMAN: true,
    version: { java_version: '17.0.1', major: 17 }
  }, {
    homedir: '/usr/lib/jvm/java-11-openjdk-amd64',
    hasJavac: true,
    version: { java_version: '11.0.7', major: 11 }
  },
...
]
*/
0.5.1

8 months ago

0.5.0

10 months ago

0.4.5

1 year ago

0.4.6

1 year ago

0.4.4

2 years ago

0.4.3

2 years ago

0.3.0

2 years ago

0.4.2-preview

2 years ago

0.4.1

2 years ago

0.4.2-preview.1

2 years ago

0.4.0

2 years ago

0.3.1

2 years ago

0.4.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago

0.1.0-preview

2 years ago