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

Commit 2684011

Browse files
authored
Merge pull request #152 from henriknyman/1.2-fix-java-version-osx
Fix Java version check for Mac OS X
2 parents 64a3990 + c1f999a commit 2684011

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

cypher-shell/src/dist/cypher-shell

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ check_java() {
1010
[[ -n "${JAVA_MEMORY_OPTS:-}" ]] && version_command+=("${JAVA_MEMORY_OPTS[@]}")
1111

1212
JAVA_VERSION=$("${version_command[@]}" 2>&1 | awk -F '"' '/version/ {print $2}')
13-
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`
14-
if [[ "${MAX_VERSION}" = "1.8" ]]; then
15-
echo "ERROR! Java version ${JAVA_VERSION} is not supported. "
16-
_show_java_help
17-
exit 1
13+
if [[ $JAVA_VERSION = "1."* ]]; then
14+
if [[ "${JAVA_VERSION}" < "1.8" ]]; then
15+
echo "ERROR! Java version ${JAVA_VERSION} is not supported. "
16+
_show_java_help
17+
exit 1
18+
fi
1819
fi
1920
}
2021

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

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

5560
case "${DIST_OS}" in
5661
"macosx")
57-
JAVA_HOME="$(/usr/libexec/java_home -v 1.8)"
62+
JAVA_HOME="$(/usr/libexec/java_home -v 1.8+)"
5863
;;
5964
"gentoo")
6065
JAVA_HOME="$(java-config --jre-home)"
@@ -63,7 +68,7 @@ _find_java_home() {
6368
}
6469

6570
_show_java_help() {
66-
echo "* Please use Oracle(R) Java(TM) 8 or OpenJDK(TM) 8."
71+
echo "* Please use Oracle(R) Java(TM) >=8 or OpenJDK(TM) >=8."
6772
}
6873

6974
build_classpath() {

0 commit comments

Comments
 (0)