Try:

~~~
  def zipWithUniqueId(): JavaPairRDD[T, java.lang.Long] = {
    JavaPairRDD.fromRDD(rdd.zipWithUniqueId().map(x => (x._1, new java.lang.Long(x._2))))
~~~