Apache Math 3.4 (and 3.3), java 1.8.0_25
import org.apache.commons.math3.distribution.ChiSquaredDistribution;
ChiSquaredDistribution chisq = new ChiSquaredDistribution(23)
System.out.println(1.0 - chisq.cumulativeProbability(130) // 1.1102230246251565E-16
System.out.println(1.0 - chisq.cumulativeProbability(131) // 0.0
Why does Apache Math return 0.0 in the second call? Some stat libraries (Excel, but not R) do return values that are much smaller than 1E-16 for the tail probabilities.
Additional Edit: In the comments below, Robert provides a direct way of calculating chi square tail probabilities using another function from Apache math library (regularizedGammaQ) that does not have this precision problem.
ChiSquaredDistribution Javadoc