This is because JRE is not present in the build path of your project. So trying adding JRE from Windows->Preferences->Installed JREs and Add the default JRE. After that the JRE gets added by default in the build path of every project. This should solve the issue