In case you are using a laptop and do not have the Pause\Break button.
For windows 10 users with 20h2 and above:
1 WIN → type "About your PC" → scroll at the bottom → Advanced system settings → Environment variables or WIN+R → shell:::{bb06c0e4-d293-4f75-8a90-cb05b6477eee}
to open Classic System Properties → on the left side → Advanced system settings → Environment variables
Also for Windows 10 and Windows 7:
1 WIN → This PC → properties → Advanced system settings → Environment variables
- In the System variables section click on New…
- In Variable name write:
JAVA_HOME
- In Variable value write:
C:\Program Files\Java\jdk-15.0.2\bin
, press OK
I have taken steps 2-4 from Vijay Bhatt
There is a bit faster way to set a system variable. Run a console (terminal) as an administrator.
General command synax to add a new variable:
setx variableName value /M
In our example, we would need to set it as
setx JAVA_HOME "C:\Program Files\Java\jdk-15.0.2\bin" /M`
Like this:
/M
- flag specifies to set the variable in the system environment.
After command execution, you should see the message:
SUCCESS: Specified value was saved.
How can I check that it is added?
- Close your active terminal;
- Open your favorite terminal;
- Type
java -version
.
You should see something similar to this:
Notice:
User variables can be created w/o having a root (administrator privileges), whereas to create System variable
; You need to open a console as a root.
I have used C:\Program Files\Java\jdk-15.0.2\bin
as an example, in your case, it could be different from mine.