For JAVA_HOME it should be C:\java, but on your Path variable, it should point to C:\java\bin\ since Path is what is used to tell the Command Prompt where to look for executables.

Answer from Michael Ziluck on Stack Overflow
🌐
Oracle
docs.oracle.com › javase › tutorial › essential › environment › paths.html
PATH and CLASSPATH (The Java™ Tutorials > Essential Java Classes > The Platform Environment)
Note: You may see a PATH environment variable similar to the following when editing it from the Control Panel: %JAVA_HOME%\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem Variables enclosed in percentage signs (%) are existing environment variables.
🌐
NTU Singapore
www3.ntu.edu.sg › home › ehchua › programming › howto › Environment_Variables.html
Environment Variables for Java Applications - PATH, CLASSPATH, JAVA_HOME
For example, to add a directory ... current user, or "/etc/profile" for ALL users. // Append a directory in front of the existing PATH export PATH=/usr/local/mysql/bin:$PATH · (For Java......
Discussions

cmd - what should be the java path in the environment variable on my system Windows 10 - Stack Overflow
Can someone please let me know what should path for java I need to mention in the environment variable. for java_home etc..Let me know if you need more info from me. I am very new to the java More on stackoverflow.com
🌐 stackoverflow.com
How to set the environment variables for Java in Windows - Stack Overflow
For example ... In environmental variable, user variable section click on New button and give path like below. after that give ok for it and go to the System variables and select the Path and double click on it. click on new and paste %JAVA_HOME%\bin and click ok to all. More on stackoverflow.com
🌐 stackoverflow.com
java adding to path
Adding something to the path just makes the commands in the folder available everywhere system wide. The way an OS (not limited to Windows) works is that it searches certain folders for the commands you enter in the terminal (console). If it doesn't find the command, it tells you that the command you entered is not recognized. By adding a folder to the path you tell the OS to also search that particular folder when you enter a command. For Java, you need javac and java from the console. The former compiles your source code, the latter executes it. Had you not added the folder to the path, you would always need to type C:\Program Files\Java\jdk-17\bin\javac when you want to compile a program. By adding the folder to the path javac becomes sufficient. More on reddit.com
🌐 r/javahelp
3
1
August 5, 2023
path - Setting up enviroment variables in Windows 10 to use java and javac - Stack Overflow
I got a new laptop with Windows ... java and javac from the command line. I have searched online but all the guides are for previous versions, and I don't want to mess around with something I don't understand. ... Save this answer. ... Show activity on this post. Just set the path variable to JDK bin in environment ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Oracle
java.com › en › download › help › path.html
How do I set or change the PATH system variable?
Click Environment Variables. In the section System Variables find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New. In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable.
🌐
Java Training School
javatrainingschool.com › home › how to set 'path' env variable
How to set ‘Path’ env variable - Java Training School
August 27, 2021 - Quiz: what happens when neither path varible is set nor complete path is given? Find answer in the below screenshot: Click on the windows button and start typing ‘environment..’ Below window will appear. Click on ‘Edit the system evnironment variables’ · 2. In the below window, click on ‘Environment Variables…’ button. 3. Following window will open, click on ‘New’ button · 4. First, we will set a new variable named as ‘JAVA_HOME’. Its value would be the location where jdk is installed.
🌐
GeeksforGeeks
geeksforgeeks.org › java › how-to-set-java-path-in-windows-and-linux
How to Set Java Path in Windows and Linux? - GeeksforGeeks
July 23, 2025 - Below is the procedure for how to set Java Path in both Windows and Linux? Step 1: Go to the Search box and type Advanced System settings in it. Now click on the View Advanced System settings. Step 2: Select the Advanced tab and then click environment variables.
🌐
javaspring
javaspring.net › blog › java-path-environment-variable
Mastering the Java Path Environment Variable — javaspring.net
You can create custom environment variables for different Java versions, for example: JAVA_8_HOME=C:\Program Files\Java\jdk1.8.0_271 JAVA_11_HOME=C:\Program Files\Java\jdk - 11.0.10 · Then, you can update the PATH variable to point to the ...
Find elsewhere
🌐
Tom Gregory
tomgregory.com › java-home-vs-path-environment-variables
JAVA_HOME vs. PATH Environment Variables | Tom Gregory
May 2, 2022 - For example, with Gradle you can set either PATH or JAVA_HOME and it will run fine. Other programs, such as the Eclipse IDE, need at least the PATH in order to startup. For the best compatibility with new and old programs that use Java always set both JAVA_HOME and PATH. If you're concerned about maintaining two environment variables...
🌐
Oracle
docs.oracle.com › cd › E19062-01 › sun.mgmt.ctr36 › 819-5418 › 6n7gk6imj › index.html
Java Environment Variables and Path (Sun Management Center 3.6.1 Installation and Configuration Guide)
The Edit System Variable window ... %SystemRoot%\system32;%SystemRoot%, the new path statement would then be %SystemRoot%\system32;%SystemRoot%;c:\j2version-number\bin where version-number is the JDK version....
🌐
Ultimate Systems Blog
blog.usro.net › ultimate systems blog › how-to › windows › how to list environment variables and find java path in windows
How to List Environment Variables and Find Java Path in Windows – Ultimate Systems Blog
December 5, 2024 - Find a Specific Variable (Optional): To view a specific variable, use: powershell $Env:VARIABLE_NAME Example: powershell $Env:PATH ... Open Environment Variable Settings: – Press Win + R, type sysdm.cpl, and press Enter.
Top answer
1 of 16
458

Java SE Development Kit 8u112 on a 64-bit Windows 7 or Windows 8

Set the following user environment variables (== environment variables of type user variables)

  • JAVA_HOME : C:\Program Files\Java\jdk1.8.0_112
  • JDK_HOME : %JAVA_HOME%
  • JRE_HOME : %JAVA_HOME%\jre
  • CLASSPATH : .;%JAVA_HOME%\lib;%JAVA_HOME%\jre\lib
  • PATH : your-unique-entries;%JAVA_HOME%\bin (make sure that the longish your-unique-entries does not contain any other references to another Java installation folder.

Note for Windows users on 64-bit systems:

Progra~1 = 'Program Files'
Progra~2 = 'Program Files(x86)'

Notice that these environment variables are derived from the "root" environment variable JAVA_HOME. This makes it easy to update your environment variables when updating the JDK. Just point JAVA_HOME to the fresh installation.

There is a blogpost explaining the rationale behind all these environment variables.

Optional recommendations

  • Add a user environment variable JAVA_TOOL_OPTIONS with value -Dfile.encoding="UTF-8". This ensures that Java (and tools such as Maven) will run with a Charset.defaultCharset() of UTF-8 (instead of the default Windows-1252). This has saved a lot of headaches when wirking with my own code and that of others, which unfortunately often assume the (sane) default encoding UTF-8.
  • When JDK is installed, it adds to the system environment variable Path an entry C:\ProgramData\Oracle\Java\javapath;. I anecdotally noticed that the links in that directory didn't get updated during an JDK installation update. So it's best to remove C:\ProgramData\Oracle\Java\javapath; from the Path system environment variable in order to have a consistent environment.
2 of 16
70

In Windows inorder to set

Step 1 : Right Click on MyComputer and click on properties .

Step 2 : Click on Advanced tab

Step 3: Click on Environment Variables

Step 4: Create a new class path for JAVA_HOME

Step 5: Enter the Variable name as JAVA_HOME and the value to your jdk bin path ie c:\Programfiles\Java\jdk-1.6\bin and

NOTE Make sure u start with .; in the Value so that it doesn't corrupt the other environment variables which is already set.

Step 6 : Follow the Above step and edit the Path in System Variables add the following ;c:\Programfiles\Java\jdk-1.6\bin in the value column.

Step 7 :Your are done setting up your environment variables for your Java , In order to test it go to command prompt and type

 java   

who will get a list of help doc

In order make sure whether compiler is setup Type in cmd

  javac

who will get a list related to javac

Hope this Helps !

🌐
GeeksforGeeks
geeksforgeeks.org › java › setting-environment-java
Setting up Environment Variables For Java - Complete Guide to Set JAVA_HOME - GeeksforGeeks
May 9, 2025 - Now, go to Environment Variable > System Variable section > click New. ... In the Variable name field, enter JAVA_HOME and in the Variable value field enter the path where the JDK is installed.
🌐
Medium
azimuahamed.medium.com › java-environment-variables-setup-windows-11-58fe71e43b5e
JAVA Environment Variables Setup Windows 11 | by Azim Uddin Ahamed | Medium
August 1, 2024 - For example, if you installed JDK 11, you might find a folder like jdk-11.x.x. ... In the System window, click on “Advanced system settings” on the left sidebar. In the System Properties window, click the “Environment Variables” button.
🌐
Oracle
docs.oracle.com › cd › E19215-01 › 820-2215 › system-prep-2 › index.html
Java Environment Variables and Path
The Edit System Variable window ... %SystemRoot%\system32;%SystemRoot%, the new path statement would then be %SystemRoot%\system32;%SystemRoot%;c:\j2version-number\bin where version-number is the JDK version....
🌐
Princeton
cs.princeton.edu › courses › archive › fall97 › cs461 › jdkdocs › tooldocs › win32 › classpath.html
classpath - Environment Variables
(for example, the Java tools located ... of CLASSPATH. You can also use set in your startup file to specify a CLASSPATH at startup. The format is: set CLASSPATH=path1;path2 ......
🌐
Reddit
reddit.com › r/javahelp › java adding to path
r/javahelp on Reddit: java adding to path
August 5, 2023 -

what does adding java to path does on windows? I started a local java short course sometime ago but I had to differ it. I started watching some online tutorials but none of them added java "to path" (system properties ->Environment Variables -> click on path -> click edit -> click new paste (C:\Program Files\Java\jdk-17\bin) which I did in the local course I joined.

Top answer
1 of 3
10
Adding something to the path just makes the commands in the folder available everywhere system wide. The way an OS (not limited to Windows) works is that it searches certain folders for the commands you enter in the terminal (console). If it doesn't find the command, it tells you that the command you entered is not recognized. By adding a folder to the path you tell the OS to also search that particular folder when you enter a command. For Java, you need javac and java from the console. The former compiles your source code, the latter executes it. Had you not added the folder to the path, you would always need to type C:\Program Files\Java\jdk-17\bin\javac when you want to compile a program. By adding the folder to the path javac becomes sufficient.
2 of 3
1
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
🌐
Baeldung
baeldung.com › home › java › core java › java_home vs path environment variables
JAVA_HOME vs PATH Environment Variables | Baeldung
January 8, 2024 - In most cases, JAVA_HOME is set to point to the JDK path instead of the JRE. This is useful for modern development tools that need access to the compiler, debugger, document generator, etc. Here’s how we set the JAVA_HOME variable through the command-line: ... Alternatively, we can also set this variable through system settings. Windows users can find this setting under the System Properties -> Advanced -> Environment Variables.
🌐
AutomationTestingHub
automationtestinghub.com › home › setup java environment variables
Setup Java Environment Variables - AutomationTestingHub
February 10, 2026 - 1. Open your JDK folder (C:\Program Files\Java\jdk-21.0.10 – as per our tutorial example) and check that it has bin folder in it · 2. Now open this bin folder and observe the entire folder location. For us, this folder location is – C:\Program Files\Java\jdk-21.0.10\bin · 3. Since the JDK folder location is already represented by JAVA_HOME variable, so we can replace the location of JDK folder with JAVA_HOME like this – %JAVA_HOME%\bin – this is what we need to update in the Path variable · 4. In the Environment variables window, check that there is a variable called Path under System variables.