The error seems to be caused by the default JRE( Java RunTime Environment) that is failing to provide the class libraries and other resources that your Java program needs to run .
Hint: Remove the default JRE present in your workspace and set it to JRE Version corresponding to your installed Java version
- Right click on your project
- Go to Build Path–> Configure Build Path .
- Go to Library. Under Module Path click JRE System Library and remove the current JRE System Linrary. The Remove Button is on the right side labelled "Remove " .
- Then click “Add Library” which is just at the right side
- Then Choose “JRE System Library”. Then click Next.
- Choose “Execution Environment” instead of “Workspace default JRE”
- Then in the drop down menu, choose the JRE version that corresponds to your installed java --version that is the JRE System Library [CDC-1.0/.Foundation 1.0]
- Then click finish
- Then click apply and Close Button
- Run the program again