Properly detect java version.