For a static, spherically symmetric, anisotropic and charged distribution of matter, we present a new class of exact solutions to the Einstein-Maxwell system. By assuming specific forms of the electric field and anisotropy, we transform the master equation of the Einstein-Maxwell system to Bessel and modified Bessel differential equations. The subsequent solutions turn out to be generalizations of the isotropic and uncharged stellar model of Finch and Skea (1989), the isotropic and charged stellar model of Hansraj and Maharaj (2006) and the anisotropic and charged stellar model of Maharaj {\em et al} (2017). We analyze the physical viability of the solutions and utilize one particular class of solutions to examine the effects of charge and anisotropy on the mass-radius relationship of compact stars.