Updated Java sample