The surface energy plays a significant role in solids and structures at the small scales, and an explicit expression for surface energy is prerequisite for studying the nanostructures via energy methods. In this study, a general formula for surface energy at finite deformation is constructed, which has simple forms and clearly physical meanings. Next, the strain energy formulas both for isotropic and anisotropic surfaces under small deformation are derived. It is demonstrated that the surface elastic energy is also dependent on the nonlinear Green strain due to the impact of residual surface stress. Then, the strain energy formula for residually stressed elastic solids is given. These results are instrumental to the energy approach for nanomechanics. Finally, the proposed results are applied to investigate the elastic stability and natural frequency of nanowires. A deep analysis of these two examples reveals two length scales characterizing the significance of surface energy. One is the critical length of nanostructures for self-buckling; the other reflects the competition between residual surface stress and surface elasticity, indicating that the surface effect does not always strengthen the stiffness of nanostructures. These results are conducive to shed light on the importance of the residual surface stress and the initial stress in the bulk solids.