Implementing OTP in JAVA