You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ja...@apache.org on 2016/09/20 09:12:37 UTC
lucene-solr:branch_6x: SOLR-8080: bin/solr start script now exits
with informative message if using wrong Java version
Repository: lucene-solr
Updated Branches:
refs/heads/branch_6x b67a062f9 -> 09d399791
SOLR-8080: bin/solr start script now exits with informative message if using wrong Java version
(cherry picked from commit 4574cb8)
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/09d39979
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/09d39979
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/09d39979
Branch: refs/heads/branch_6x
Commit: 09d399791a37681b5233248841bae738b799d8e1
Parents: b67a062
Author: Jan H�ydahl <ja...@apache.org>
Authored: Tue Sep 20 10:56:25 2016 +0200
Committer: Jan H�ydahl <ja...@apache.org>
Committed: Tue Sep 20 10:58:34 2016 +0200
----------------------------------------------------------------------
solr/CHANGES.txt | 2 ++
solr/bin/solr | 33 +++++++++++++++++++++++++++------
2 files changed, 29 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/09d39979/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 79b3cb4..91b89b7 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -107,6 +107,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
----------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/09d39979/solr/bin/solr
----------------------------------------------------------------------
diff --git a/solr/bin/solr b/solr/bin/solr
index ff804af..46903e7 100755
--- a/solr/bin/solr
+++ b/solr/bin/solr
@@ -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