fixed up java sample code in docs

fixes #2572