Apache Lucene open-source search software
SOLR-7024: bin/solr: Improve java detection and error messages
Shawn Heiseyd17e8133e0e6
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 3c87304d2b8..f0647cb2eca 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -540,6 +540,10 @@ Bug Fixes* SOLR-6856: Restore ExtractingRequestHandler's ability to capture all HTML tags whenparsing (X)HTML. (hossman, ehatcher, Steve Rowe)+* SOLR-7024: Improved error messages when java is not found by the bin/solr+ shell script, particularly when JAVA_HOME has an invalid location.+ (Shawn Heisey)+Optimizations----------------------diff --git a/solr/bin/solr b/solr/bin/solrindex 01db4255fef..4ce235d8e16 100755--- a/solr/bin/solr+++ b/solr/bin/solr@@ -119,12 +119,27 @@ elif [ -n "$JAVA_HOME" ]; thenbreakfidone+ if [ -z "$JAVA" ]; then+ echo >&2 "The currently defined JAVA_HOME ($JAVA_HOME) refers"+ echo >&2 "to a location where Java could not be found. Aborting."+ echo >&2 "Either fix the JAVA_HOME variable or remove it from the"+ echo >&2 "environment so that the system PATH will be searched."+ exit 1+ fielseJAVA=javafi# test that Java exists and is executable on this server-$JAVA -version >/dev/null 2>&1 || { echo >&2 "Java is required to run Solr! Please install Java 7 or 8 before running this script."; exit 1; }+$JAVA -version >/dev/null 2>&1 || {+ 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 "Active Path:"+ echo >&2 "${PATH}"+ exit 1+}# URL scheme for contacting SolrSOLR_URL_SCHEME=http