Java version of CreateMagnet