Skip to content
This repository has been archived by the owner on Jul 6, 2023. It is now read-only.

Commit

Permalink
Fix Java version check for Mac OS X
Browse files Browse the repository at this point in the history
  • Loading branch information
henriknyman committed May 31, 2019
1 parent 90cf424 commit c1f999a
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions cypher-shell/src/dist/cypher-shell
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ check_java() {
[[ -n "${JAVA_MEMORY_OPTS:-}" ]] && version_command+=("${JAVA_MEMORY_OPTS[@]}")

JAVA_VERSION=$("${version_command[@]}" 2>&1 | awk -F '"' '/version/ {print $2}')
MAX_VERSION=`echo -e "$JAVA_VERSION\n1.8" | sort -t '.' -k 1,1 -k 2,2 -k 3,3 -k 4,4 -g | tail -1`
if [[ "${MAX_VERSION}" = "1.8" ]]; then
echo "ERROR! Java version ${JAVA_VERSION} is not supported. "
_show_java_help
exit 1
if [[ $JAVA_VERSION = "1."* ]]; then
if [[ "${JAVA_VERSION}" < "1.8" ]]; then
echo "ERROR! Java version ${JAVA_VERSION} is not supported. "
_show_java_help
exit 1
fi
fi
}

Expand All @@ -25,6 +26,10 @@ _find_java_cmd() {

if [[ "${JAVA_HOME:-}" ]] ; then
JAVA_CMD="${JAVA_HOME}/bin/java"
if [[ ! -f "${JAVA_CMD}" ]]; then
echo "ERROR: JAVA_HOME is incorrectly defined as ${JAVA_HOME} (the executable ${JAVA_CMD} does not exist)"
exit 1
fi
else
if [ "${DIST_OS}" != "macosx" ] ; then
# Don't use default java on Darwin because it displays a misleading dialog box
Expand Down Expand Up @@ -54,7 +59,7 @@ _find_java_home() {

case "${DIST_OS}" in
"macosx")
JAVA_HOME="$(/usr/libexec/java_home -v 1.8)"
JAVA_HOME="$(/usr/libexec/java_home -v 1.8+)"
;;
"gentoo")
JAVA_HOME="$(java-config --jre-home)"
Expand All @@ -63,7 +68,7 @@ _find_java_home() {
}

_show_java_help() {
echo "* Please use Oracle(R) Java(TM) 8 or OpenJDK(TM) 8."
echo "* Please use Oracle(R) Java(TM) >=8 or OpenJDK(TM) >=8."
}

build_classpath() {
Expand Down

0 comments on commit c1f999a

Please sign in to comment.