SOLR-8080: bin/solr start script now exits with informative message if using wrong Java version

This commit is contained in:
Jan Høydahl 2016-09-20 10:56:25 +02:00
parent 3712bf5819
commit 4574cb8cea
2 changed files with 29 additions and 6 deletions

View File

@ -137,6 +137,8 @@ Bug Fixes
* SOLR-9512: CloudSolrClient will try and keep up with leader changes if its
state cache points to a down server (Alan Woodward, noble)
* SOLR-8080: bin/solr start script now exits with informative message if using wrong Java version (janhoy)
Optimizations
----------------------

View File

@ -49,6 +49,9 @@ SOLR_SCRIPT="$0"
verbose=false
THIS_OS=`uname -s`
# What version of Java is required to run this version of Solr.
JAVA_VER_REQ="8" # For printing in echo
stop_all=false
# for now, we don't support running this script from cygwin due to problems
@ -116,16 +119,34 @@ else
JAVA=java
fi
# test that Java exists and is executable on this server
"$JAVA" -version >/dev/null 2>&1 || {
# test that Java exists, is executable and correct version
JAVA_VER=$("$JAVA" -version 2>&1)
if [[ $? -ne 0 ]] ; then
echo >&2 "Java not found, or an error was encountered when running java."
echo >&2 "A working Java 8 is required to run Solr!"
echo >&2 "Please install Java 8 or fix JAVA_HOME before running this script."
echo >&2 "Command that we tried: '${JAVA} -version'"
echo >&2 "A working Java $JAVA_VER_REQ JRE is required to run Solr!"
echo >&2 "Please install latest version of Java $JAVA_VER_REQ or set JAVA_HOME properly."
echo >&2 "Command that we tried: '${JAVA} -version', with response:"
echo >&2 "${JAVA_VER}"
echo
echo >&2 "Debug information:"
echo >&2 "JAVA_HOME: ${JAVA_HOME:-N/A}"
echo >&2 "Active Path:"
echo >&2 "${PATH}"
exit 1
}
else
JAVA_VER=$(echo $JAVA_VER | awk -F '"' '/version/ {print $2}')
if [[ "$JAVA_VER" < "1.$JAVA_VER_REQ" ]] ; then
echo >&2 "Your current version of Java is too old to run this version of Solr"
echo >&2 "We found version $JAVA_VER, using command '${JAVA}'"
echo >&2 "Please install latest version of Java $JAVA_VER_REQ or set JAVA_HOME properly."
echo
echo >&2 "Debug information:"
echo >&2 "JAVA_HOME: ${JAVA_HOME:-N/A}"
echo >&2 "Active Path:"
echo >&2 "${PATH}"
exit 1
fi
fi
# Select HTTP OR HTTPS related configurations
SOLR_URL_SCHEME=http