java impelemntation