In this paper we use a numerical method to study the quantum effect of dynamical localization on the supercurrent in a mesoscopic Josephson junction driven by a periodically external electromagnetic field. We find that the charge is localized effectively when the ratio of the field magnitude and the field frequency equal some critical values, and in these cases the amplitude of the oscillation of the supercurrent will remain constant.