[#1871] Refactor getJavaVersion