I found a similar error as mine on stackoverflow and added selenium webdriver jar files to the project using the below method :
right click on project--> goto build path--> configure build path--> click on "Add external jars"--> add selenium jar files from your local machine--> click ok--> now mouseover on WebDriver in your code--> click "import webdriver"--now run your code-->you will get rid of the exception.
However, I am still getting an error. Here's the error :
Exception in thread "main" java.lang.Error: Unresolved compilation problems: WebDriver cannot be resolved to a type FirefoxDriver cannot be resolved to a type