Added java and c++ versions