Skip to content

JAVA_HOME ignored on MacOS/Darwin #9

@lionello

Description

@lionello

Actual

I have JAVA_HOME environment variable set to the path of a valid JDK, but locate-java-home does not find it.

Expected

The value of JAVA_HOME should always be considered a reasonable candidate when checking for a valid java-home.

Root cause

Turns out on MacOS only the output of /usr/libexec/java_home is used and that one ignores whatever is in JAVA_HOME.

Fix

Add this snippet from linux.ts to darwin.ts line 22:

    // Option 2: Is JAVA_HOME defined?
    // (NOTE: locate_java_home will prune redundancies.)
    if (process.env.JAVA_HOME) {
      installations.push(process.env.JAVA_HOME!);
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions