Skip to content

Instantly share code, notes, and snippets.

@mattvryan
Created January 20, 2015 17:05
Show Gist options
  • Save mattvryan/c99c19fdc2a6a36ce99a to your computer and use it in GitHub Desktop.
Save mattvryan/c99c19fdc2a6a36ce99a to your computer and use it in GitHub Desktop.
Bash script snippet to check Java version (e.g. in an init script)
JAVA=`which java`
JAVA_VERSION=$("$JAVA" -version 2>&1 | awk -F '"' '/version/ {print $2}' | sed 's/\(.*\)\.\(.*\)\..*/\1\2/')
if [ "$JAVA_VERSION" -lt 17 ]; then
echo "Invalid Java version found - must be at least 1.7"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment