As with the Javascript renderer, I wrote some fluid sim code in Java a few years back and it’s now ported over to JS. The code works using smoothed particle hydrodynamics, i.e. modelling using particles of fixed mass. This technique is used on a large scale in film effects to do water simulations as in The Day After Tomorrow etc.
You can see the simulation at the below link, click-drag-release on the particles to add forces into the simulation. As before I recommend using a browser with a good JS implementation to run this code (e.g. Chrome).
Fluid simulation (2500 particles)