'Is it guaranteed that the term "version" appears in the output of `java -version`?

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?



Solution 1:[1]

I second like Stephen C that this is no guarantee but a solid practice. However the different vendors are likely to follow one pattern in their line, and there are just a few relevant vendors anyway.

It would not be too tyring to check relevant vendor's distribution (and their names for sure show up) and implement it from there.

If you want a fully standardized solution you could also create a java class that is to be executed with the JVM in question. This java class would print the content of the system properties. These are standardized and contain specification version as well as implementation version.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Hiran Chaudhuri