  Josephson currents are carried by sharp Andreev states within the
superconducting energy gap. We theoretically study the electronic transport of
a magnetically tunable nanoscale junction consisting of a quantum dot connected
to two superconducting leads and coupled to the spin of a molecular magnet. The
exchange interaction between the molecular magnet and the quantum dot modifies
the Andreev states due to a spin-dependent renormalization of the quantum dot's
energy level and the induction of spin-flips. A magnetic field applied to the
central region of the quantum dot and the molecular magnet further tunes the
Josephson current and starts a precession of the molecular magnet's spin. We
use a non-equilibrium Green's function approach to evaluate the transport
properties of the junction. Our calculations reveal that the energy level of
the dot, the magnetic field and the exchange interaction between the molecular
magnet and the electrons occupying the energy level of the quantum dot can
trigger transitions from a 0 to a $\pi$ state of the Josephson junction. The
redistribution of the occupied states induced by the magnetic field strongly
modifies the current-phase relation. The critical current exhibits a sharp
increase as a function of either the energy level of the dot, the magnetic
field or the exchange interaction.
