I had to change the algorithm with java. Instead of the standard rook and bishop move generation, I split them up into directions and then get each direction individually. This is slower but stops me needing a 64x4096 and 64x512 array. This exceeds the max size for a class, so I went with this approach. I finally got java to work after loads of trial and error. Having to use signed longs can cause many problems in certain situations. Like in bitScanForward.