Java implementation