Improve Java version detection

Java version detection of the Un*x start scripts depends on the version to be
in the first line and the implementation name in the second line. However this
is not always true, e.g. when properties are set via environment variable.

Example:
	export _JAVA_OPTIONS=""
	java -version

This commit will make the version position independent, however it still
assumes that the line containing the implementation name will follow the
version line.
This commit is contained in:
Ignaz Forster 2014-11-18 14:24:18 +01:00
parent 717694a77b
commit b9c887076e
2 changed files with 4 additions and 4 deletions

View file

@ -113,7 +113,7 @@ check_java() {
"$JAVA_EXE" -version > "$VERSION_FILE" 2>&1 || rm -f "$VERSION_FILE"
if [ -r "$VERSION_FILE" ]; then
JAVA_VERSION=`cat "$VERSION_FILE" | head -n 1 | awk '{ print substr($3, 2, length($3)-2); }'`
JAVA_VERSION=`cat "$VERSION_FILE" | awk '/^java version/ { print substr($3, 2, length($3)-2); }'`
if [ "x$OS_NAME" = "xSunOS" ]; then
echo " Java version: $JAVA_VERSION \c"
else
@ -128,7 +128,7 @@ check_java() {
if [ "$JAVA_VERSION" ]; then
if [ "$JAVA_VERSION" -ge "$MIN_JAVA_VERSION" ]; then
echo "OK"
JAVA_IMPL=`cat "$VERSION_FILE" | head -n 2 | "$TAIL_COMMAND" -n 1 | awk '{ print $1; }'`
JAVA_IMPL=`cat "$VERSION_FILE" | awk '/^java version/ { getline; print $1; }'`
if [ "x$OS_NAME" = "xSunOS" ]; then
echo " Java implementation: $JAVA_IMPL \c"
else

View file

@ -113,7 +113,7 @@ check_java() {
"$JAVA_EXE" -version > "$VERSION_FILE" 2>&1 || rm -f "$VERSION_FILE"
if [ -r "$VERSION_FILE" ]; then
JAVA_VERSION=`cat "$VERSION_FILE" | head -n 1 | awk '{ print substr($3, 2, length($3)-2); }'`
JAVA_VERSION=`cat "$VERSION_FILE" | awk '/^java version/ { print substr($3, 2, length($3)-2); }'`
if [ "x$OS_NAME" = "xSunOS" ]; then
echo " Java version: $JAVA_VERSION \c"
else
@ -128,7 +128,7 @@ check_java() {
if [ "$JAVA_VERSION" ]; then
if [ "$JAVA_VERSION" -ge "$MIN_JAVA_VERSION" ]; then
echo "OK"
JAVA_IMPL=`cat "$VERSION_FILE" | head -n 2 | "$TAIL_COMMAND" -n 1 | awk '{ print $1; }'`
JAVA_IMPL=`cat "$VERSION_FILE" | awk '/^java version/ { getline; print $1; }'`
if [ "x$OS_NAME" = "xSunOS" ]; then
echo " Java implementation: $JAVA_IMPL \c"
else