apolloconfig / apollo-quick-start

Apollo Quick Start
691 stars 1.85k forks source link

启动demo.sh的时候报jdk版本问题 #83

Closed ForeverKang closed 2 years ago

ForeverKang commented 2 years ago

我是jdk11版本,但是启动demo.sh的时候报版本不能低于1.8 Java version is 11.0.13, please make sure java 1.8+ is in the path 这个问题如何解决

nobodyiam commented 2 years ago

The java version check logic is as follows, but it's strange that it works in my environment (mac os). You may first comment the version check logic. BTW, what's your operating environment?

https://github.com/apolloconfig/apollo-build-scripts/blob/fa578778c9f0b707b26661c4104236b720eedb71/demo.sh#L89-L96

version=11.0.13
if [[ "$version" < "1.8" ]]; then
echo "$version is < 1.8"
else
echo "$version >= 1.8"
fi

The result is:

11.0.13 >= 1.8
nobodyiam commented 2 years ago

Another solution is to transform the version string to digits

      version=$("$_java" -version 2>&1 | awk -F '"' '/version/ {print $2}')
      version_in_digit=$(echo "$version" | awk -F. '{printf("%03d%03d",$1,$2);}')
      if [[ $version_in_digit < 001008 ]]; then
          echo "Java version is $version, please make sure java 1.8+ is in the path"
          exit 1
      fi