I'm new to batch script coding and a little stuck here. I've got a .sh file that checks if version of java installed is at least 1.8.0:
# Minimal version
MINIMAL_VERSION=1.8.0
# Check if Java is present and the minimal version requirement
_java=`type java | awk '{ print $ NF }'`
CURRENT_VERSION=`"$_java" -version 2>&1 | awk -F'"' '/version/ {print $2}'` #says 1.8.0_65
minimal_version=`echo $MINIMAL_VERSION | awk -F'.' '{ print $2 }'` #says 8
current_version=`echo $CURRENT_VERSION | awk -F'.' '{ print $2 }'` #says 8
if [ $current_version ]; then
if [ $current_version -lt $minimal_version ]; then
echo "Error: Java version is too low. At least Java >= ${MINIMAL_VERSION} needed.";
exit 1;
fi
else
echo "Not able to find Java executable or version. Please check your Java installation.";
exit 1;
fi
It is pretty clear. I need to write a .bat file for Windows exactly same logic. So here's where I'm stuck, because I do not know windows analogs for awk.