RFC4226 HOTP Java Implementation
The change to Math.pow() didn't make any difference, but I think you might be making the call to generateOTP() with 0 as the truncationOffset parameter value. Trying this with -1 gives the reference test vectors.
Change
int otp = binary % DIGITS_POWER[codeDigits];
To
int otp = (int) (binary % Math.pow(10, codeDigits));
Or
int otp = binary % 1000000;