private static int parseDotted ( String javaVersion ) { try { String [ ] parts = javaVersion . split ( "[._]" ) ; int firstVer = Integer . parseInt ( parts [ 0 ] ) ; if ( firstVer == 1 && parts . length > 1 ) { return Integer . parseInt ( parts [ 1 ] ) ; } else { return firstVer ; } } catch ( NumberFormatException e ) { return - 1 ; } }
Parses both legacy 1 . 8 style and newer 9 . 0 . 4 style