java implementation of kdyn.py