Today while writing test class in eclipse i saw below error:
- This was happening due to my JRE was not set. To find it right click project –> Properties –> Java Build Path –> Click Libraries tab as shown below:
- To set JRE into build path click Add Library…
- Select JRE System Library –> Click Next
- Choose Workspace default JRE or Alternate installed JRE (If you want to install new JRE please use this link : Install new JRE eclipse ) . I choosen Workspace default JRE as below then click finish:
- Now you will see on Libraries tab new JRE system Library is set and active
- Click OK to finish it. This should resolve the issue.
Solution 2:
- Sometime you will see JRE system libraries is already set but still it gives error. To resolve this
- Click project –> Properties –> Java Build Path –> Click Libraries tab –>Select existing JRE or installed new JRE as shown below and click OK to rebuild the project.
- This should resolve the issue.