We know that by equations

J.E +1/2 [d/dt (E.D) +d/dt (H.B) +div (E x H) =0

For a non-conductive media J = 0. We get

½[d/dt (E.D.) + d/dt (H.B) ] + div (E*H) = 0

ð ½[d/dt (E.D.) + d/dt (H.B) ] + div P = 0

ð ½[d/dt (εE^{2}) + d/dt (µH^{2}) ] + div P = 0

Energy density = ½ (εE^{2}) + ½ (µH^{2})

d/dt.µ + div P = 0

div P + du/dt = 0

This equation is same as equation of the continuity

Div J + dp/dt = 0

Since equation of continuity represents the law of conservation of charge. So by analogy the previous equation must represent the law of conversation of energy for electromagnetic field.