public static int compareVersion(String version1,String version2){
  String[] partsv1=version1.split("\\.");
  String[] partsv2=version2.split("\\.");
  int len=Math.min(partsv1.length,partsv2.length);
  for (int i=0; i < partsv1.length && i < len; i++) {
    Integer iv1=Integer.parseInt(partsv1[i]);
    Integer iv2=Integer.parseInt(partsv2[i]);
    if (iv1.compareTo(iv2) != 0)     return iv1.compareTo(iv2);
  }
  return 0;
}

public static int compareVersion ( String version1 , String version2 ) { String [ ] partsv1 = version1 . split ( "\\." ) ; String [ ] partsv2 = version2 . split ( "\\." ) ; int len = Math . min ( partsv1 . length , partsv2 . length ) ; for ( int i = 0 ; i < partsv1 . length && i < len ; i ++ ) { Integer iv1 = Integer . parseInt ( partsv1 [ i ] ) ; Integer iv2 = Integer . parseInt ( partsv2 [ i ] ) ; if ( iv1 . compareTo ( iv2 ) != 0 ) return iv1 . compareTo ( iv2 ) ; } return 0 ; }
compares two version strings of format x . y . z , where x is major , y is minor , and z is maintenance release .
