I do not recommend using correlations as a measure of independence. Basically Pearson product-moment correlation coefficient is a measure of linear correlation, which is often not the case. On the other hand Spearman's rank or Kendall tau rank correlations works also for non-linear correlated variables. However, my understanding about those procedures is that if those procedures might fail to "capture" the correlation, that does not mean at all that automatically those variables are independent.
More appropriate for this kind of task are what are called independence tests, and among them is the well-known Pearson's chi-squared test. See wiki page.
I have no experience with using independence test, but the last book I studied states that is more appropriate to use G-Test. More details here on wiki page.
I currently build my own library for statistical and ml stuff and I did not yet implemented those tests, only some correlations. But I take a look on those pages and does not seem to be complex or hard to implement in any language.
I expect, however, to have some troubles generating random samples for distributions other than discrete uniform or normal Gaussian, since as far as I know, Java offers support only for those distributions.