Added Java implementation.