Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

Commit 8b1a507

Browse files
committed
use highest available java version for execution if JVMversion is NOT specified // refs #37
1 parent 9da7364 commit 8b1a507

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

src/universalJavaApplicationStub

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -408,17 +408,34 @@ elif [ ! -z ${JVMVersion} ] ; then
408408
exit 3
409409
fi
410410

411-
# otherwise check "/usr/libexec/java_home" symlinks
412-
elif [ -x /usr/libexec/java_home ] && /usr/libexec/java_home -F > /dev/null; then
413-
JAVACMD="`/usr/libexec/java_home 2> /dev/null`/bin/java"
411+
# otherwise check "/usr/libexec/java_home" and Oracle and Apple JRE paths and use highest version available
412+
else
414413

415-
# otherwise check Java standard symlink (old Apple JRE)
416-
elif [ -h /Library/Java/Home ]; then
417-
JAVACMD="${apple_jre_plugin}"
414+
# first check "/usr/libexec/java_home" symlinks
415+
if [ -x /usr/libexec/java_home ] && /usr/libexec/java_home -F > /dev/null 2>&1 ; then
416+
JAVACMD="`/usr/libexec/java_home 2> /dev/null`/bin/java"
417+
JAVACMD_version=$(comparableJavaVersionNumber $(extractJavaVersionString "${JAVACMD}"))
418+
fi
418419

419-
# fallback: public JRE plugin (Oracle Java)
420-
else
421-
JAVACMD="${oracle_jre_plugin}"
420+
# then additionally check the Oracle JRE plugin whether it's a higher/newer compatible version
421+
if [ -x "${oracle_jre_plugin}" ] ; then
422+
this_java_ver=$(comparableJavaVersionNumber $(extractJavaVersionString "${oracle_jre_plugin}"))
423+
# use this compatible version only if the above returned empty or if the version number is higher
424+
if [ -z ${JAVACMD} ] || [ ${this_java_ver} -ge ${JAVACMD_version} ] ; then
425+
JAVACMD="${oracle_jre_plugin}"
426+
JAVACMD_version=${this_java_ver}
427+
fi
428+
fi
429+
430+
# then additionally check the Apple JRE plugin whether it's a higher/newer compatible version
431+
if [ -x "${apple_jre_plugin}" ] ; then
432+
this_java_ver=$(comparableJavaVersionNumber $(extractJavaVersionString "${apple_jre_plugin}"))
433+
# use this compatible version only if the above returned empty or if the version number is higher
434+
if [ -z ${JAVACMD} ] || [ ${this_java_ver} -ge ${JAVACMD_version} ] ; then
435+
JAVACMD="${apple_jre_plugin}"
436+
JAVACMD_version=${this_java_ver}
437+
fi
438+
fi
422439
fi
423440

424441
# fallback fallback: /usr/bin/java

0 commit comments

Comments
 (0)