Java port of x2