adding some usefull code to the Java sample
docs