Hi!
There is an EXCELLENT blog answer that covers this in great detail with full easy-to-understand descriptions of how to fix ALL these kind of problems. Here's the link:
http://camerarepair.blogspot.com/2007/12/fixing-lens-error-on-digital-camera.html
Don't let the year in the link "fool you", it is not dated - it is constantly updated & current :0)
Also, just as a quick general answer, most problems revolve around tiny dirt/dust particles making there way into the mechanism.... in my situation (my Coolpix s5100) had jammed similarly - but it was cuz the camera had overheated in the 111F heat we had today. I simply cooled the camera at home & then, took the battery in-&-out to reset it, gently tapped the side of the camera - and now it works again ;0)
Anyway, whatever the cause, simply go to that blog link, you'll find EXCELLENT advise there - it TOTALLY helped me!
GOOD LUCK :0)
-MAR