There's a 10 year old question, Correct way to check Java version from BASH script. Obviously some flaws of that approach were already pointed out, since we no longer have "the Java", but also OpenJDK and others.
Does Java guarantee that the output always contains the term "version", i.e. it must neither be translated, nor abbreviated ("v.") and also not omitted?