I have a time series of data (about 300-750 elements, depending on the sample) and a model that has some random residues. I used the Kolmogorov–Smirnov test to make sure that the normality hypothesis can't be rejected, so I assume that the residuals are normally distributed. But now I guess I should test if they are independent of each other - so that there is no autoregression? Which test should I use (preferably one that is easily implementable in java)?
You could try Runs test for randomness. I am not familiar with Java functions. I got a link related to runs test that may useful to you. JAVA NPST. Apart from this you could do durbin-watson test or Ljung-Box portmanteau test. Most important is the visual check of time series plot ( I guess you have done this already).
Another option is a permutation test. Compute a measure of autocorrelation, then randomly permute the values and recompute the same measure of autocorrelation. Do the permute and recompute step a bunch of times (like 2,000 overall) and compare the value for the original ordering to the permuted values to do the test.