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
🌐
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......
🌐
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.
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_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
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
🌐
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.
🌐
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....
🌐
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.
Find elsewhere
🌐
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.
🌐
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 ...
🌐
Tom Gregory
tomgregory.com › gradle › java-home-vs-path-environment-variables
JAVA_HOME vs. PATH Environment Variables | Tom Gregory
May 2, 2022 - OK...so we nailed PATH. Why on earth do we need JAVA_HOME as well then? The JAVA_HOME environment variable is set to the JDK installation directory.
🌐
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.
🌐
Cleverence
cleverence.com › articles › oracle-documentation › setting-an-environment-variable-for-java-5824
How to Set Java Environment Variables (JAVA_HOME, PATH) on Windows, macOS, and Linux
May 3, 2026 - Under User variables or System variables, create JAVA_HOME and set it to your JDK path, for example C:\Program Files\Java\jdk-21. Next, edit PATH and add %JAVA_HOME%\bin at the top so it wins over older installs.
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 !

🌐
George Washington University
www2.seas.gwu.edu › ~simhaweb › lin › submit › env-variables › env.html
Environment variables
For example, when using the pico editor, this is what it will look like: ... Just for demonstration, let's create our own new environment variable, after our PATH variable. export PATH=$PATH:/Library/Java/JavaVirtualMachines/jdk-10.0.2.jdk/Contents/Home/bin export MY_ENV_VAR=Hello
🌐
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.
🌐
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....
🌐
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...
🌐
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.
🌐
Cleverence
cleverence.com › articles › oracle-documentation › java-environment-variables-and-path-5821
Java Environment Variables: Configure JAVA_HOME, PATH, and CLASSPATH on Windows, macOS, and Linux
March 13, 2026 - To set JAVA_HOME via GUI: open System Properties, Advanced, then Environment Variables. Under System variables, create JAVA_HOME with the JDK path (e.g., C:\\Program Files\\Java\\jdk-21). Then edit PATH and add %JAVA_HOME%\bin near the top.