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
This commit is contained in:
Shawn Heisey 2015-01-24 00:02:25 +00:00
parent 6dcfa17adc
commit d17e8133e0
2 changed files with 20 additions and 1 deletions

View File

@ -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
----------------------

View File

@ -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