How to set JAVA_HOME on Windows 10?
This tutorial shows you how to set a JAVA_HOME
system variable on Windows 10.
Tested with :
- Windows 10
- JDK 1.8
1. Advanced System Settings
Type advanced system settings
in the search box (beside the Windows start button), clicks View advanced system settings
.
2. Environment Variables
Select Advance
tab, clicks Environment Variables
3. Add JAVA_HOME
In System variables, clicks New...
button to add a new JAVA_HOME
variable and point it to the JDK installed folder.
Note
Don’t include the
Don’t include the
\bin
folder, just the JDK path. For example
- Correct – C:\Program Files\Java\jdk1.8.0_60
- Wrong – C:\Program Files\Java\jdk1.8.0_60\bin
4. Update PATH
In System variables, find PATH
, clicks edit...
button :
4.1 In old version of Windows, it will prompt you below dialog box to edit the values directly, append this %JAVA_HOME%\bin;
to the end of the line.
4.2 In latest Windows 10, it will prompt you below dialog box, clicks on New
button, and add this %JAVA_HOME%\bin
Note
Puts the
Puts the
%JAVA_HOME%\bin
in PATH
make all the Java’s commands (java, javac, jstack and etc) are accessible from everywhere.
5. Test
Open a command prompt, type :
C:\Users\mkyong>java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
C:\Users\mkyong>javac -version
javac 1.8.0_60
C:\Users\mkyong>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.8.0_60
Hii,
Mkyong i have windows 10 .i have installed jdk1.8.0_77 and also include jre1.8.0_77.first i setup envirment as your avobe instruction.Then i go to cmd promt type java -version run successfully but when i type javac -version error is occured i.e ‘javac’ is not recognized as an internal or external command,
operable program or batch file.
Okay the problem here is that adding %JAVA_HOME%\bin to the path file DOES NOT WORK. Instead, go to file explorer and location the bin folder inside your jdk directory, copy the folder path and add it to the path file. This should resolve javac. In the future, authors should understand what does and doesn’t work before writing a tutorial.
I think you forgot to set JAVA_HOME variable.
after completing the system variable settings you better close the command prompt and open again and then you try these commands. For me it worked like that only
This works. Thanks.
that works))) thx man!!!
thanks buddy
This.
I had the same problem, “javac -version” was not being recognised.
So I googled and came across a “stackoverflow.com” article. It mentioned about using location the JDK bin folder.
So I first added “%JAVA_HOME%\bin”
Then I added my address for JDK bin folder.
And that seem to fix my “javac -version” problem.
I don’t know if this is the best “solution”, I’m a noob, just learning.
Here’s a link to the article:
https://stackoverflow.com/questions/44344519/getting-javac-is-not-recognised-as-internal-or-external-command-operable-progr
try java -version instead. That’ll work after you’ve set the path.
Read Step 4, you need to add %JAVA_HOME%bin to the PATH.
i now fixed it by adding a semicolon before appending it to the path.
this is also my question, is there any explanations now as to why javac -version didn’t work?
when you write paths do it without any white spaces.
Hi Mykong.
when i type ‘echo %JAVA_HOME%’ I only get ‘ %JAVA_HOME%’ as the response
Hi Mykong.
when i type ‘echo %JAVA_HOME%’ I only get ‘ %JAVA_HOME%’ as the response
Used Command prompt instead of power shell for “echo %JAVA_HOME%” to work
I had the same problem. Try to write command in “Command Prompt” insted of Powershell
I have the same problem
instead of adding %JAVA_HOME%\bin to the system variable, I put the whole path like C:\Program Files\Java\jdk1.8.0_201\bin and it worked
both methods do not seem to work for me. The java -version command works though.
This one worked for me thanks
Seems in some cases that placeholder method does not work out… same issue on my engine.
Windows+pause key works in windows 10? because that can also help in opening advance system settings dialog…
THANK YOU FOR SHORTCUT BROTHER—-
Thanks for your shortcut, yes it works. Windows key + Pause Key will prompts the “advance system settings”
Hi am getting error but in command prompt java is working fine . but having an issue with maven.. pls help me am using java1.8 and windows10 os
Windows 10 Path-section fix.
If you click edit on the paths section and it has 4 of them or more, just ADD a new path and make it the ‘%JAVA_HOME%bin’
This is what worked for me, there was nothing for me to add it to the end to that was similar to the video, but I made it it’s own option and it worked.
Yes, in latest Windows, the dialog box is changed. Thanks for your help.
Article is updated to include this situation, thanks.
how to make it ‘%JAVA_HOME%bin’. I mean I can add a new path and give the path of my java Bin there. what else do I need to do?
Thanks buddy.. This worked for me..
javac -version not worked for me windows 10 latest i m using
The year is 2020, and I use this again
Hi Everyone and Mkyong, Java SE 8 jdk8u_66 I want to set up to Windows 10, I can’t make the JVM, set beyond the flesh I can’t do, please help you be?
Sorry, what is your problem?
Hi @mkyong, can you please confirm below queries?
Thanks! Really appreciated!
Hello. Thank you very much !
It’s worked perfely! Thanks for your user friendly documentation, which is very helpful for beginers like me. Appreciate your efforts.
good
tank you so much
Hi Mkyong! Thank you very much, Just folowed each step and it’s worked like a charm.
Thank You! It worked for me
THANK YOU MISTER
Thank you sir.
Thank you for helping me out.
How should I install Tomcat under powershell on Windows 10? It reports Invalid path always
Very good tutorial, than you so much!
C:\Users\HP>javac -version
‘javac’ is not recognized as an internal or external command,
operable program or batch file.
do you have like button in your post? I feel like you deserved it!
Thank you, I have no how to use allure without JAVA_HOME.
Hi
Can i use any other name instead of java_home
Yes you can. I tried it works
In setting the path variable , use the path actul where your JDK (bin ) is stored
Thank you very much for the explanation.
thank you
java _version
Error: Could not find or load main class _version
Ok… sorry… it’s ” dash – ” NOT “underscore _ ” Never mind.
Thanks for sharing
on my windows10 pro , I had to add the path into “path” and include the “\bin” (jdk 14.0.2)
the JAVA_HOME didn’t work
anyway thank you for this page. it still helped