On the origin of the moons of Jupiter