  We systematically calculate the relativistic corrections to the polarization
variables of 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, especially at small transverse momentum $p_T$
and large inelasticity $z$. The results obtained here and in our previous work
on the unpolarized yield [Phys. Rev. D 90, 014045 (2014)] will help to render
global analyses of prompt $J/\psi$ production data more complete and hopefully
to shed light on the $J/\psi$ polarization puzzle.
