|MadSci Network: Physics|
Simply spinning a metallic object won't give you a magnetic field. In the laboratory, you need to run a current through a conductor in order to do that. Planetary bodies generate their magnetic fields using the so-called "dynamo effect."
Three things appear to be necessary in order for the dynamo effect to operate. First, the planet must have some kind of liquid, conductive core. In the case of the Earth, the core consists of molten iron and nickel. In the case of Jupiter, it is primarily liquid metallic hydrogen. Secondly, the planet must be spinning rapidly. Finally, it must have convective motions within its core. These elements together are apparently capable of driving the electric currents needed to generate magnetic fields.
The detailed picture is fairly complicated, and not completely understood. A reasonable introduction is given in Chapter 26 of "The Physics of Astrophysics, Vol. 2" by Frank Shu.
[note added by MadSci Admin: There are also some previous answers in our archives that discuss electromagnetism and the generation of magnetic fields. The files can be found using our search engine.]
Try the links in the MadSci Library for more information on Physics.