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 08:57:27 UTC

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

Repository: lucene-solr
Updated Branches:
  refs/heads/master 3712bf581 -> 4574cb8ce


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


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/4574cb8c
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/4574cb8c
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/4574cb8c

Branch: refs/heads/master
Commit: 4574cb8ceafad2e2530955923946d16f2cf71a96
Parents: 3712bf5
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:56:25 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/4574cb8c/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index d1d9cfb..4531a5d 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -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
 ----------------------
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/4574cb8c/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