Universal Robots+

Linux - Install.sh fails with Java version 11.0.0

This is with the latest version of the URSim (5.9).

The install.sh script checks for java versions later than 1.6. Unfortunately, it does a string compare and concludes than “11.0.8” is less that “1.6” and so quits with a failure of “java version is too old”.

To fix this UR needs to rework the string. I’ve updated mine to trip off the major version and just compare that to 1.6 as a number using the ‘bc’ utility.

needToInstallJava() {
    echo "Checking java version"
    if command -v java; then
	# source https://stackoverflow.com/questions/7334754/correct-way-to-check-java-version-from-bash-script
        version=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}')

	echo "Stripping the front end"
	majorVersion=${version%%.*}
        echo Java major version "$majorVersion"
	if [ "`echo "$majorVersion > 1.6" | bc`" -eq 1 ]; then
	    echo "java version accepted"
            return 0
	fi
    fi
    return 1
}