Examples showing how to compare two RGB colors using the CIE ΔE2000 in Java are here.
The procedure involves converting colors from RGB space to L*a*b* space to calculate the distance between them. The ΔE2000 is a modern metric for comparing two colors in the CIELAB color space, which improves on the earlier CIE76 formula by integrating new perceptual factors, resulting in more accurate color comparisons.