Every physics student knows that the energy of an electromagnetic field is equal to $1/2(E^2+B^2)$. However, there are a lot of ways to obtain this formula. Some lecturers use heuristic arguments about transferring charged particles from infinity. Another idea is to derive it from the energy-momentum tensor - then the canonical energy-momentum tensor must be artificially improved by Belinfante-Rosenfeld procedure to obtain the desired formula. However, these derivations are not so satisfying from the formal and physical point of view. I will show how to obtain this formula as a generating function of dynamics using symplectic formalism proposed by W. M. Tulczyjew in a paper A Symplectic Framework of Linear Field Theories. First, I will define the energy of a field in every linear field theory using symplectic space associated with current given by the three-dimensional volume $V$ and transversal time vector field on it. Next, I will show how to apply this construction to Maxwell electrodynamics, and how it can be useful in proving the existence of a solution of the initial-boundary problem by evolutionary methods.