I created the redeem Script as follows:
Script redeemScript=scriptbuilder.createRedeemScript(2, pubkeys);
Then in order to get the bytes of the script i used the :
byte[] bytesFromScript=myScript.getProgram();
and finally in got the hash of the Script using the RIPEMD160(SHA256(bytesFromScript)) procedure.
The Script class doesn't have any other function to get the bytes so i used the getProgram() function.
Am i wrong to this?