  We systematically calculate the relativistic corrections to prompt $J/\psi$
photoproduction and hadroproduction using the factorization formalism of
nonrelativistic QCD. Specifically, we include the ${}^3\!S_1^{[1]}$ and
${}^3\!P_{J}^{[1]}$ color-singlet and the ${}^3\!S_1^{[8]}$,
${}^1\!S_{0}^{[8]}$, and ${}^3\!P_{J}^{[8]}$ color-octet channels as well as
the effects due to the mixing between the ${}^3\!S_1^{[8]}$ and
${}^3\!D_1^{[8]}$ channels. We provide all the squared hard-scattering
amplitudes in analytic form. Assuming the nonrelativistic-QCD long-distance
matrix elements to satisfy the velocity scaling rules, we find the relativistic
corrections to be appreciable, except in the ${}^3\!S_1^{[1]}$ color-singlet
channel of hadroproduction. We also observe significant differences in the line
shapes of the relativistic corrections between photoproduction and
hadroproduction.
