Above error shows up when you do not have JRE or JDK not added to your build path. This is the well-known bug with Eclipse.
The possible solution is
- Close the project and reopen it.
- Clean the project (It will rebuild the build path hence reconfiguring with the JDK libraries OR
- Delete and Re-import the project and if necessary do the above steps again
If above steps do not work, you can add workspace default JRE as below.
- Right-click on project » Properties » Java Build Path
- Select Libraries tab
- Find the JRE System Library and remove it
- Click Add Library... button at right side » Add the JRE System Library (Workspace default JRE)
You can even include custom JDK you have installed on your OS as below.
- Right-click your project > properties
- Select âJava Build Pathâ on left, then âJRE System Libraryâ, click Editâ¦
- Select "Workspace Default JRE"
- Click "Installed JREs"
- If you see JRE you want in the list select it (selecting a JDK is OK too)
- If not, click Searchâ¦, navigate to Computer > Windows C: > Program Files > Java, then click OK
- Select the one you want and click OK/Finish
Now you should see all installed JREs, select the one you want