code: public static int compareVersions(String version_1, String version_2)
  	{
  		for (int j = 0; j < Math.min(version_2.length(), version_1.length()); j++)
  		{
  
  			char v1_c = version_1.charAt(j);
  			char v2_c = version_2.charAt(j);
  
  			if (v1_c == v2_c)
  			{
  
  				continue;
  			}
  
  			if (v2_c == '.')
  			{
  
  				// version1 higher (e.g. 10.2 -vs- 1.2)
  
  				return (+1);
  
  			} else if (v1_c == '.')
  			{
  
  				// version2 higher ( e.g. 1.2 -vs- 10.2 )
  
  				return (-1);
  
  			} else
  			{
  
  				return (v1_c - v2_c);
  			}
  		}
  
  		// longest one wins. e.g. 1.2.1 -vs- 1.2
  
  		return (version_1.length() - version_2.length());
  	}
docs: compare two version strings of form n.n.n.n (e.g. 1.2.3.4)
  
  @param version_1
  @param version_2
  @return -ve -> version_1 lower, 0 = same, +ve -> version_1 higher