For Windows 10:
1. Right click on My Computer
4. Select Advanced tab
5. Select Environment Variables
6.
Select Path under System Variables
7.
Click on Edit button
8.
In Variable value editor click on new
button
9.
paste this at the start of the line
C:\Program Files\Java\jdk1.8.0_242\bin;
[ TIP : Don’t forget to add ‘;’at the end ]
10.
Click Ok then Ok again
11.
Restart command prompt otherwise it
won't see the change to the path variable
12.
Type java
-version in command prompt