write docs and Java sample