private static int compareVersions(String v1,String v2){
  String[] parts1=v1.split("\\.");
  String[] parts2=v2.split("\\.");
  int len=Math.max(parts1.length,parts2.length);
  for (int i=0; i < len; i++) {
    int p1=0;
    int p2=0;
    try {
      p1=Integer.parseInt(parts1[i],10);
    }
 catch (    Exception ex) {
    }
    try {
      p2=Integer.parseInt(parts2[i],10);
    }
 catch (    Exception ex) {
    }
    int comp=p1 - p2;
    if (comp != 0)     return comp;
  }
  return 0;
}

private static int compareVersions ( String v1 , String v2 ) { String [ ] parts1 = v1 . split ( "\\." ) ; String [ ] parts2 = v2 . split ( "\\." ) ; int len = Math . max ( parts1 . length , parts2 . length ) ; for ( int i = 0 ; i < len ; i ++ ) { int p1 = 0 ; int p2 = 0 ; try { p1 = Integer . parseInt ( parts1 [ i ] , 10 ) ; } catch ( Exception ex ) { } try { p2 = Integer . parseInt ( parts2 [ i ] , 10 ) ; } catch ( Exception ex ) { } int comp = p1 - p2 ; if ( comp != 0 ) return comp ; } return 0 ; }
compare two version numbers
