Skip to content
Permalink
Browse files
Add attribution for version parsing
  • Loading branch information
davecromberge committed Sep 1, 2021
1 parent cd8993d commit 8d5f520101e64a8af9bf49c67aa3f66c5ae2e984
Showing 1 changed file with 4 additions and 0 deletions.
@@ -70,6 +70,10 @@ fi

#### Parse java -version into major version number ####
if [[ "$Java_" ]]; then
# This expression extracts the correct major version of the Java runtime.
# For older runtime versions, such as 1.8, the leading '1.' is removed.
# Adapted from this answer on StackOverflow:
# https://stackoverflow.com/questions/7334754/correct-way-to-check-java-version-from-bash-script/56243046#56243046
JavaVersion=$("$Java_" -version 2>&1 | head -1 | cut -d'"' -f2 | sed '/^1\./s///' | cut -d'.' -f1)
else
echo "No version information could be determined from installed JDK."; exit 1;

0 comments on commit 8d5f520

Please sign in to comment.