Hello @Pankaj162,
Welcome back to the HP Support Forums!
I understand that you are having an issue with the Optical Drive, and wanted to assist you! I see that the issue started, after installing Windows 8 on a new Hard Drive.
I would like to make sure that I understand the situation. You opened the notebook to replace the Hard Drive. Did you replace the Hard Drive with a compatible replacement for the notebook? Next, you closed everything up, and opened the Optical Drive to insert the Windows 8 disc. After installing Windows 8 on the new Hard Drive, you opened the Optical Drive and removed the disc. Afterwards, you tried to close the Optical Drive, without success. Is this correct? Are you able to see, or check if anything is stuck? You can try opening the notebook, to see if there was anything missed or not connected properly. Keep in mind that you may have to have the drive bay closed, in order to open the notebook. If you are unable to get the drive bay closed, then you will need to contact HP Phone Support for additional options.
Please let me know if this information helps you resolve the issue by marking this post as "Accept as Solution", this will help others easily find the information they may be looking for. Also, clicking the Thumbs up below is a great way to say thanks!
Have a great day!