The default java installation for ubuntu is openjdk, not the version from Oracle. This means that
java -version
shows
$ java -version
openjdk version "11.0.3" 2019-04-16
OpenJDK Runtime Environment (build 11.0.3+7-Ubuntu-1ubuntu218.04.1)
OpenJDK 64-Bit Server VM (build 11.0.3+7-Ubuntu-1ubuntu218.04.1, mixed mode, sharing)
grep "java version"
isn't going to find a match, thus the function returns nothing.
Points to Richard for pointing out that your code is different between
mycode
and the
var =
versions.