To tell eclipse to use JDK, you have to follow the below steps.
- Select the Window menu and then Select Preferences. You can see a dialog box.
- Then select Java ---> Installed JRE’s
- Then click Add and select Standard VM then click Next
- In the JRE home, navigate to the folder you’ve installed the JDK (For example, in my system my JDK was in C:\Program Files\Java\jdk1.8.0_181\ )
- Now click on Finish.
After completing the above steps, you are done now and eclipse will start using the selected JDK for compilation.