We reexamine the classical virial theorem for bounded orbits of arbitrary autonomous Hamiltonian systems possessing both regular and chaotic orbits. New and useful forms of the virial theorem are obtained for natural Hamiltonian flows of arbitrary dimension. A discrete virial theorem is derived for invariant circles and periodic orbits of natural symplectic maps. A weak and a strong form of the virial theorem are proven for both flows and maps. While the Birkhoff Ergodic Theorem guarantees the existence of the relevant time averages for both regular and chaotic orbits, the convergence is very rapid for the former and extremely slow for the latter. This circumstance leads to a simple and efficient measure of chaoticity. The results are applied to several problems of current physical interest, including the Henon-Heiles system, weak chaos in the standard map, and a 4D Froeschle map.