  Elastic virtual photoproduction of charmonia on nucleons is calculated in a
parameter free way with the light-cone dipole formalism and the same input:
factorization in impact parameters, light-cone wave functions for the photons
and the charmonia, and the universal phenomenological dipole cross section
which is fitted to other data. The charmonium wave functions are calculated
with four known realistic potentials, and two models for the dipole cross
section are tested. Very good agreement with data for the cross section of
charmonium electroproduction is found in a wide range of $s$ and $Q^2$. Using
the ingredients from those calculations we calculate also exclusive
electroproduction of charmonia off nuclei. Here new effects become important,
(i) color filtering of the $c\bar c$ pair on its trajectory through nuclear
matter, (ii) dependence on the finite lifetime of the $c\bar c$ fluctuation
(coherence length) and (iii) gluon shadowing in a nucleus compared to the one
in a nucleon. Total coherent and incoherent cross sections for C, Cu and Pb as
functions of $s$ are presented. The results can be tested with future
electron-nucleus colliders or in the peripheral collisions of relativistic
heavy ions.
