Skip to content

Commit

Permalink
fix: Ensure JAVA_HOME path comes first in the PATH environment
Browse files Browse the repository at this point in the history
  • Loading branch information
breautek committed May 9, 2021
1 parent 6bd740d commit e70e078
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions bin/templates/cordova/lib/env/java.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,9 @@ const java = {
const javacPath = utils.forgivingWhichSync('javac');
const hasJavaHome = !!environment.JAVA_HOME;
if (hasJavaHome) {
// Windows java installer doesn't add javac to PATH, nor set JAVA_HOME (ugh).
if (!javacPath) {
environment.PATH += path.delimiter + path.join(environment.JAVA_HOME, 'bin');
}
// Ensure that the JAVA_HOME bin path is before anything else
// to cover cases where different Java versions is in the PATH
environment.PATH = path.join(environment.JAVA_HOME, 'bin') + path.delimiter + environment.PATH;
} else {
if (javacPath) {
// OS X has a command for finding JAVA_HOME.
Expand Down

0 comments on commit e70e078

Please sign in to comment.