From d17e8133e0e6b9095209ba104b3cdf944283dbe8 Mon Sep 17 00:00:00 2001 From: Shawn Heisey Date: Sat, 24 Jan 2015 00:02:25 +0000 Subject: [PATCH] SOLR-7024: bin/solr: Improve java detection and error messages git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1654434 13f79535-47bb-0310-9956-ffa450edef68 --- solr/CHANGES.txt | 4 ++++ solr/bin/solr | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 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 when parsing (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/solr index 01db4255fef..4ce235d8e16 100755 --- a/solr/bin/solr +++ b/solr/bin/solr @@ -119,12 +119,27 @@ elif [ -n "$JAVA_HOME" ]; then break fi done + 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 + fi else JAVA=java fi # 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 Solr SOLR_URL_SCHEME=http