Helmholtz proposed that the sun's energy comes from gravitational
contraction. Under this theory, the sun could not be more than about 20
million years old.
Helmholtz's theory has been discredited. It is now known that the sun
gets its energy from nuclear fusion.
Even ignoring the evidence for fusion, gravitational contraction fails
for other reasons. It does not explain the relationship between
stellar temperatures and luminosity, and it is inconsistent with
variable stars.