From c54064ee2099dea14bba7cc369498a40ed87314d Mon Sep 17 00:00:00 2001 From: hengyunabc Date: Fri, 31 Aug 2018 11:55:55 +0800 Subject: [PATCH] as.sh support java 11 --- bin/as.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bin/as.sh b/bin/as.sh index a3269af60..f3cfb50dc 100755 --- a/bin/as.sh +++ b/bin/as.sh @@ -99,12 +99,20 @@ reset_for_env() done fi + # maybe 1.8.0_162 , 11-ea + local JAVA_VERSION_STR=$(${JAVA_HOME}/bin/java -version 2>&1|awk -F '"' '$2>"1.5"{print $2}') # check the jvm version, we need 1.6+ - local JAVA_VERSION=$(${JAVA_HOME}/bin/java -version 2>&1|awk -F '"' '$2>"1.5"{print $2}') - [[ ! -x ${JAVA_HOME} || -z ${JAVA_VERSION} ]] && exit_on_err 1 "illegal ENV, please set \$JAVA_HOME to JDK6+" + [[ ! -x ${JAVA_HOME} || -z ${JAVA_VERSION_STR} ]] && exit_on_err 1 "illegal ENV, please set \$JAVA_HOME to JDK6+" + + local JAVA_VERSION + if [[ $JAVA_VERSION_STR = "1."* ]]; then + JAVA_VERSION=$(echo $veJAVA_VERSION_STRr | sed -e 's/1\.\([0-9]*\)\(.*\)/\1/; 1q') + else + JAVA_VERSION=$(echo $JAVA_VERSION_STR | sed -e 's/\([0-9]*\)\(.*\)/\1/; 1q') + fi # when java version greater than 9, there is no tools.jar - if [[ ! "$JAVA_VERSION" =~ ^9 ]];then + if [[ "$JAVA_VERSION" -lt 9 ]];then # check tools.jar exists if [ ! -f ${JAVA_HOME}/lib/tools.jar ]; then exit_on_err 1 "${JAVA_HOME}/lib/tools.jar does not exist, arthas could not be launched!"