A variational formulation for finite isothermal deformations of isotropic hyperelastic materials is presented. This is equivalent to nonlinear elastic field (Lagrangean) equations expressed in terms of the displacement field and a scalar function that is associated with the hydrostatic mean stress when specialized to classical elasticity. The variational formulation is particularly useful in the development of finite element analysis of nearly incompressible and incompressible materials. For slightly compressible materials small volume changes are not assumed in our model. The formulation gives a reasonable transition of results for materials varying from compressible to incompressible and is general in the sense that it admits a general form of constitutive equation. The formulation for incompressible materials is recovered from the compressible one simply as a limit. It can be considered as an extension of Herman's principle to nonlinear elasticity. Several numerical simulations are presented that show the performance of the proposed formulation and the convergence behavior of different types of elements for compressible and incompressible elasticity.