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
java.com › en › download › help › path.html
How do I set or change the PATH system variable?
Making changes to the system PATH variable is typically not necessary for computers running Windows or Mac OS X. In Search, search for and then select: System (Control Panel) Click the Advanced system settings link. Click Environment Variables. In the section System Variables find the PATH ...
Discussions

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
What are we actually doing when setting Environment path variable?
When you write a command on the shell, the system searches the PATH for that command, and then executes it. For example, suppose you are using Windows, the prompt looks like this: C:\> Suppose you type this command: tickle me elmo That command says to look for a program called "tickle" (on Windows this program would be called something like tickle.exe or tickle.bat) and to pass that program the two arguments "me" and "elmo". Since "tickle" is not a built-in shell command (like "cd"), how the system looks for that command is by searching the PATH. Every directory on the PATH is searched in order. If a program called "tickle" (or tickle.exe, etc. on Windows) is found in the first path on PATH, then that program is called. If there is no "tickle" command on the first path in PATH, then the second path in PATH searched, and so on. If no program called "tickle" is found anywhere on the PATH, then you get some sort of error message. On Windows it looks something like this: 'tickle' is not recognized as an internal or external command ... So the analogy of the word 'PATH' is that you are walking down a path, perhaps in a market. You walk down the path and look at various things in the market, and eventually settle on one thing or another. At least that's the idea that I get from the word PATH being chosen for this concept. This idea works pretty similarly on Windows, Linux, and macOS. The details and error messages are slightly different though. For example on Windows, the current directory (C:\ in the above example) is always searched, even if it is not on the PATH. On Windows, there are certain file extensions that are searched as well (e.g. tickle.exe, tickle.bat, tickle.cmd). On Windows, PATH entries are separated by ; instead of :, and on Linux and macOS PATH entries are separated by : instead of ;. Also, on Windows, PATH is also used for looking up dynamic library files (also called DLLs). On Linux, the environment variable LD_LIBRARY_PATH is used instead for dynamic library files. I'm not sure what macOS uses for library files. So how does this relate to Java? For Java the most likely commands you are going to use are 'java' and 'javac'. When you set your PATH to use Java, you are probably making it easy for you to call those programs. 'java' is the command for the Java JVM, and 'javac' is the command for the Java compiler. More on reddit.com
🌐 r/learnprogramming
7
2
May 13, 2020
Automatically Updating the Java Path in the Environment Variables
I need to setup a task on a few machines with apps that require the correct Java version path in their environment variables. This was suggested, but requires some work apparently: Remove-PathFolders -Folders “\Java\jdk” -EnvironmentVariableTarget $([System.EnvironmentVariableTarget]::Machine) ... More on community.spiceworks.com
🌐 community.spiceworks.com
4
2
May 24, 2018
%JAVA_HOME% and %Path% variables set correctly. Java returning wrong version.
Check your path. I think if you have both java versions listed in the path it uses the first it finds. More on reddit.com
🌐 r/javahelp
4
1
September 9, 2022
🌐
Baeldung
baeldung.com › home › java › core java › java_home vs path environment variables
JAVA_HOME vs PATH Environment Variables | Baeldung
January 8, 2024 - The operating system uses the PATH environment variable to find the native executable programs to run. In Windows, the executable programs end with a .exe extension. Once we point the executable program’s directory in PATH, we can invoke the ...
🌐
Oracle
docs.oracle.com › cd › F74770_01 › English › Installing › p6_eppm_install_config › 89522.htm
Setting an Environment Variable for Java
February 2, 2024 - In the System Properties dialog box, on the Advanced tab, click Environment Variables. ... In the System Variables section, click New. In the Variable name field, enter JAVA_HOME. In the Variable value field, enter the location where the JDK software is installed (for example, C:\Program ...
🌐
Oracle
docs.oracle.com › javase › tutorial › essential › environment › paths.html
PATH and CLASSPATH (The Java™ Tutorials > Essential Java Classes > The Platform Environment)
Set the PATH environment variable if you want to be able to conveniently run the executables (javac.exe, java.exe, javadoc.exe, and so on) from any directory without having to type the full path of the command.
🌐
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 - PATH is an environment variable that is used by Operating System to locate the exe files (.exe) or java binaries ( java or javac command). The path once it is set, cannot be overridden.
Find elsewhere
🌐
IBM
ibm.com › docs › en › b2b-integrator › 6.2.0
Setting Java variables on Windows
JAVA_HOME and PATH variables are required for the operating system to find the required Java programs and utilities.
🌐
Specinnovations
help.specinnovations.com › configuring-java-home-on-windows
Configuring JAVA_HOME Environment Variable on Windows
In the System variables section of the Environment Variables dialog, scroll through the list to find JAVA_HOME. ... Select JAVA_HOME and click Edit…. In the Edit System Variable dialog, paste the copied JDK path (e.g., C:\Program Files\Java\jdk-21) into the Variable value field.
🌐
Quora
quora.com › What-environment-variables-should-be-set-for-Java-PATH
What environment variables should be set for Java PATH? - Quora
Answer: set the Temporary Path of JDK in Windows To set the temporary path of JDK, you need to follow the following steps: * Open the command prompt * Copy the path of the JDK/bin directory * Write in command prompt: set path=copied_path for e.g - set path=C:\Program Files\Java\jdk1.6.0_23\b...
🌐
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 - In the Environment Variables window, under the “System variables” section, click “New.” · For the “Variable name,” enter JAVA_HOME. For the “Variable value,” enter the path to your JDK installation directory.
🌐
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)
Place /usr/j2se/bin in your PATH before /usr/bin. Place /usr/bin in your PATH before /usr/ucb. Choose Start -> Settings -> Control Panel. Double-click System. On Microsoft Windows NT, select the Environment tab. On Microsoft Windows 2000, select the Advanced tab and then Environment Variables.
🌐
Provar Testing
documentation.provar.com › home › devops with v2 › apache ant › setting java development kit (jdk) environment variables
Java Development Kit (JDK) Environment Variables | Provar
April 5, 2024 - Above: View of the Environment Variables dialog box. Step 3: Click the New button below System variables. Step 4: Within the Variable name field, enter JAVA_HOME. Within the Variable value field, enter the directory where Java JDK was extracted previously, e.g., C:\Program Files\Java\jdk1.8.0_221. Step 5: Then click the OK button. Above: View of New System Variable dialog box. Step 6: Click the Edit button to the Path variable in the System variables section.
Top answer
1 of 2
2

In short, it provides a list of directories where executable files can be found without specifying the full-path to the binary.

If you open a command-line-interface on your machine, you can type many commands without having to specify the path to the program. i.e. fdisk, shutdown, ipconfig, nslookup, etc... Keep in mind, that there are also some built-in commands that are built into the command-line-interpreter that are not a separate program... like dir, echo, cls, etc...

The purpose the JRE/JDK wants to modify your PATH environment variable is simply to be able to type java at the command-line without having to specify the full path (i.e. "c:\Program Files (x86)\Java\jre1.8.0_211\bin\java.exe")

You can modify/view your own PATH environment variable by clicking on the search-bar in windows, and type in "edit the system environment variables".

There are actually 2 sets of environment variables, and they will get merged when you open the command prompt. The ones listed under "System variables" affect the whole system, and all users that log into that computer. The ones listed under "User variables for blahblah" only affect the currently logged in user.

2 of 2
0

Basically, the PATH it defines a set of directories on which programs will be searched for when only the program name is provided, instead of an absolute/relative path.

This is how the OS can find the right program to run when you only type "java" in the terminal, for instance.

Otherwise you would have to provide the full path, like "%JAVA_HOME%/bin/java".

🌐
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.
🌐
Coderanch
coderanch.com › t › 778789 › java › Add-entry-path-environment-variable
Add entry to path environment variable mac (Beginning Java forum at Coderanch)
January 10, 2024 - Unlike Windows, where the PATH is a bit magical, Unix PATH is a simple environment variable assigned with the values of zero or more directories. The command "echo $PATH" will tell you what those directories are. Typically, /bin and /usr/bin are assigned (and inherited) from your session's ...
🌐
Reddit
reddit.com › r/learnprogramming › what are we actually doing when setting environment path variable?
r/learnprogramming on Reddit: What are we actually doing when setting Environment path variable?
May 13, 2020 -

I am learning Java, and after installing the jdk, I had to set the PATH Environment Variable. In simple words, what am I actually doing?

Top answer
1 of 2
7
When you write a command on the shell, the system searches the PATH for that command, and then executes it. For example, suppose you are using Windows, the prompt looks like this: C:\> Suppose you type this command: tickle me elmo That command says to look for a program called "tickle" (on Windows this program would be called something like tickle.exe or tickle.bat) and to pass that program the two arguments "me" and "elmo". Since "tickle" is not a built-in shell command (like "cd"), how the system looks for that command is by searching the PATH. Every directory on the PATH is searched in order. If a program called "tickle" (or tickle.exe, etc. on Windows) is found in the first path on PATH, then that program is called. If there is no "tickle" command on the first path in PATH, then the second path in PATH searched, and so on. If no program called "tickle" is found anywhere on the PATH, then you get some sort of error message. On Windows it looks something like this: 'tickle' is not recognized as an internal or external command ... So the analogy of the word 'PATH' is that you are walking down a path, perhaps in a market. You walk down the path and look at various things in the market, and eventually settle on one thing or another. At least that's the idea that I get from the word PATH being chosen for this concept. This idea works pretty similarly on Windows, Linux, and macOS. The details and error messages are slightly different though. For example on Windows, the current directory (C:\ in the above example) is always searched, even if it is not on the PATH. On Windows, there are certain file extensions that are searched as well (e.g. tickle.exe, tickle.bat, tickle.cmd). On Windows, PATH entries are separated by ; instead of :, and on Linux and macOS PATH entries are separated by : instead of ;. Also, on Windows, PATH is also used for looking up dynamic library files (also called DLLs). On Linux, the environment variable LD_LIBRARY_PATH is used instead for dynamic library files. I'm not sure what macOS uses for library files. So how does this relate to Java? For Java the most likely commands you are going to use are 'java' and 'javac'. When you set your PATH to use Java, you are probably making it easy for you to call those programs. 'java' is the command for the Java JVM, and 'javac' is the command for the Java compiler.
2 of 2
1
Maybe in some not so simple words, since this is overall an interesting and useful topic. Environment variables are a set of variables accessible to each program alongside the more common command line arguments. On Unix systems these variables are lines of text, each line a different variable in the form of: =. These lines are passed from parent to child process. This means that if you change or add a variable in one shell, this change is visible to that shell and any program you run from there, but isn't visible to programs run else where. I'm not sure how this is solved on windows, but I would expect something similar (except that Windows doesn't have the same process hierarchy). Some of these variables have special meanings, and can change the behaviour of programs. The variable PATH for instance, tells bash (and other programs as well) where to look for commands. So when you type the command "java", it first checks if this is a built-in commands. Since it's not it searchers every directory in the PATH variable, to see if it can find the program "java" there. On Linux these are widely used as an alternative way of configuring the behaviour of commands/programs. One of their benefits is, because of their propagation, it's easy to set up separately configured environments in different shells.
🌐
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 to the PATH environment variable, add the following line at the end of "~/.bashrc" (or "~/.bash_profile", or "~/.profile"), where ~ denotes the home directory of the 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) You can set the CLASSPATH environment variables by adding the following line.
🌐
Atlassian
confluence.atlassian.com › spaces › DOC › pages › 8895 › Setting+the+JAVA_HOME+Variable+in+Windows
Setting the JAVA_HOME Variable in Windows | Confluence Data Center 10.2 | Atlassian Documentation
setx /m JAVA_HOME "C:\Program Files\Java\jdk11.0.17.8" Restart Command Prompt to reload the environment variables then use the following command to check the it's been added correctly. ... You should see the path to your JDK (or JRE) installation.