You can receive the unsigned long as long, as "long" as one does not calculate with the long. You can even display that long as unsigned using Long.toUnsignedString(n).
Otherwise store it in a BigInteger. Ideally loaded as 8 big-endian bytes.
// Some snippets, unordered, showing useful constructs.
long n = ...;
n = Long.reverseBytes();
byte[] bigendian = new byte[8];
ByteBuffer buf = ByteBuffer.wrap(bigendian); // .order(ByteOrder.LITTLE_ENDIAN);
buf.putLong(n);
// Creating a BigInteger from unsigned long's bytes, requiring big-endian order.
BigInteger num = new BigInteger(1, bigendian); // 1 = positive
uint64should be analogous to Java'slong. Can you include some data which is causing this problem?uint64is unsigned, whereas Java'slongis signed. So any number in the top half ofuint64's range will end up negative when it is interpreted as along.