optimize: support get java cmd from which java (#11720)

This commit is contained in:
jimin 2024-02-20 10:51:16 +08:00 committed by GitHub
parent e6eb636aed
commit 3c278edba9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -47,7 +47,12 @@ if [ -z "$JAVA_HOME" ]; then
fi
fi
if [ -z "$JAVA_HOME" ]; then
error_exit "Please set the JAVA_HOME variable in your environment, We need java(x64)! jdk8 or later is better!"
JAVA_PATH=$(which java)
if [ -z "$JAVA_PATH" ]; then
error_exit "Please set the JAVA_HOME variable in your environment, We need java(x64)! jdk8 or later is better!"
fi
JAVA_HOME=$(dirname "$JAVA_PATH")/..
export JAVA_HOME=$(cd "$JAVA_HOME" && pwd)
fi
fi