C++ to java from AIJunkie