Added Java example + minor fixes

Added the Java example, and made minor fixes in the comments of the C++
example.