The xdmp:hash64 algorithm is proprietary and has unknown properties. You could send every input from Java to MarkLogic, to ask it what the hash is. But I'd look for a hash algorithm that's available in both environments.
Depending on your needs, SHA-2 may be a suitable choice: https://docs.marklogic.com/xdmp:sha512 or xdmp:sha384
or xdmp:sha256
.
You asked for a 64-bit number like xdmp:hash64
produces: 64-bit unsigned longs. The SHA-2 functions return hex or base64 strings, but hex is easy to work with:
xdmp:hex-to-integer(xdmp:sha512('fubar'))
If that throws XDMP-FIPSWEAKHASH
then your cluster is in FIPS mode. In that case you have to use the HMAC variant, by adding a secret key:
xdmp:hex-to-integer(xdmp:hmac-sha512('s3cr!t', 'fubar'))
=> 18446744073709551615
For equivalent Java code SHA2 password hashing in java may help. As long as you use the same algorithm and key on both sides you should be fine.
Note that working with unsigned 64-bit long integers may not be ideal for Java, because Java doesn't have unsigned 64-bit longs as a primitive type. I understand JDK8 offers some help. But comparing hex strings might turn out to be as easy and efficient as any other solution.