adding java implementation