How I fixed the java.lang,ClassNotFoundException

image

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

  1. Right click on your project
  2. Go to Build Path–> Configure Build Path .
  3. 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 " .
  4. Then click “Add Library” which is just at the right side
  5. Then Choose “JRE System Library”. Then click Next.
  6. Choose “Execution Environment” instead of “Workspace default JRE”
  7. 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]
  8. Then click finish
  9. Then click apply and Close Button
  10. Run the program again
4 Likes

Hi @suubi7

So nice of you to pen down the issue and walkaround to help others

Thank you

3 Likes