Device-to-Device (D2D) communication is one of the technologies for next generation communication system. Unlike traditional cellular network, D2D allows proximity users to communicate directly with each other without routing the data through a base station. The main aim of this study is to improve the overall energy efficiency (EE) of D2D communications overlaying cellular system. To reduce the complexity of joint EE optimization, we decompose the main EE problem into two subproblems; resource efficiency (RE) optimization in the first stage and EE optimization for D2D pairs in the second stage. Firstly, we propose an alternative two-stage RE-EE scheme for a single cellular user equipment (CUE) and a D2D pair utilizing uplink spectrum. Later, we extend this work for multiple CUEs and D2D pairs by considering the downlink orthogonal frequency division multiple access (OFDMA). By exploiting a range of optimization tools including the Bisection method, interior point algorithm, fractional programming, Dinkelbach approach, Lagrange dual decomposition, difference of convex functions, and concave-convex procedure, the original non-convex problems are solved and we present iterative two-stage RE-EE solutions. Simulation results demonstrate that the proposed two-stage scheme for uplink scenario outperforms the cellular mode and dedicated mode of communications and the performance is close to the global optimal solution. The results also show that the proposed schemes for downlink resource sharing provide improved system EE performance with significant gain on EE for D2D users compared to a two-stage EE-EE solution, which is obtained numerically. Furthermore, the RE and EE optimization for non-orthogonal multiple access (NOMA) are considered to study the effect of usersâ access to the whole spectrum. The results indicate that the proposed RE scheme for NOMA with D2D communications achieves higher system EE compared to the OFDMA based schemes.