Here we will derive the equation for the field, potential, and energy of a uniformly charged sphere.

Assume the total charge of the sphere is Z, the radius is R. The electric field outside the sphere is,

$\displaystyle \vec{E(r)} = \frac{Ze}{4\pi\epsilon_0 r^2} \vec{r}$

Inside the sphere, at radius $r$, the charge outside formed a shell that the electric field cancelled out. Assume the charge density $Ze = \rho \frac{4\pi}{3} r^3$, and $dq = Ze r^3/R^3$, thus, the electric field at radius r is,

$\displaystyle \vec{E(r)} = \frac{dq}{4\pi \epsilon_0 r^2} \vec{r}= \frac{Ze r}{4 \pi \epsilon_0 R^3} \vec{r}$

For the potential, outside is integrate the electric field from infinite to radius r, using,

$\displaystyle V(x) - V(y) = \int_{y}^{x} \vec{E(r)} \cdot d\vec{r}$

$\displaystyle V(r>R) = V(\infty) + \int_{\infty}^{r > R} \frac{Ze}{4\pi\epsilon_0 r^2} dr = \frac{Ze}{4\pi\epsilon_0 r}$

$\displaystyle V(r

If I set the term $Ze / 4 \pi \epsilon_0 = 1$, and $R = 1$.

From this calculation, we can imagine a proton moving from the center of nuclei to the outside, it will gain energy of $Z^2 e^2 / 8 \pi \epsilon_0 R$. Of course, in the meantime, there is a proton moving from outside to the center.

The self energy is the energy to form the uniform charged sphere. We can imagine the sphere started from nothing, an a tiny bit of charge at the center, and a shell of tiny charge formed on outside, so on, and so on. The electric energy is

$\displaystyle W = \int V(r) dq$

Because the extra charge is always from from outside, the potential is

$\displaystyle V(r ) = \frac{Ze r^3/R^3}{4\pi\epsilon_0 r} = \frac{Ze}{4\pi\epsilon_0 R^3} r^2$

$dq = \rho 4\pi r^2 dr$

$\displaystyle W = \int_0^R \frac{Ze}{4\pi\epsilon_0 R^3} r^2 \rho 4\pi r^2 dr = \frac{Ze\rho}{\epsilon_0 R^3}\int_0^R r^4 dr \\ = \frac{Ze \rho}{\epsilon_0 R^3} \frac{R^5}{5} = \frac{Ze 3 \rho}{4\pi\epsilon_0 R} \frac{4\pi}{3}\frac{R^3}{5} = \frac{3}{5} \frac{Z^2 e^2}{\epsilon_0 R}$

In the last step, we used $Z e = \rho \frac{4\pi}{3} R^3$.