If you don't have admin rights, use the below command to set environment variables for java using the command prompt

setx JAVA_HOME "C:\Program Files\Java\jdk1.8.0"
setx PATH "%PATH%;%JAVA_HOME%\bin";

Modify the environment variable.

setx -m JAVA_HOME "C:\Program Files\Java\jdk1.8.0"
setx -m PATH "%PATH%;%JAVA_HOME%\bin";
Answer from Sathiamoorthy on Stack Overflow
🌐
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.
🌐
XDA Developers
xda-developers.com › home › windows11 › how to set the java path in windows 11
How to set the Java path in Windows 11
November 29, 2023 - Go back to the Environment Variables window we mentioned in step 3, and look for PATH under System variables. Click on it and then click Edit. Next, click New, and now add your bin path — in this example, it would be “C:\Program Files\Java\jdk-21\bin” · Hit OK, hit OK again, and you’re done! You are now ready to build Java apps on your Windows 11 ...
🌐
MakeUseOf
makeuseof.com › home › windows › how to set up the java_home variable on windows 11
How to Set Up the JAVA_HOME Variable on Windows 11
September 22, 2023 - In the Variable name field, type JAVA_HOME and in the Variable value field, paste the copied address. Screenshot by Aman Kumar -- no attribution required ... Return to the Environment Variables window, select Path in the System variables section, and click Edit.
🌐
GeekChamp
geekchamp.com › home › how to setup environment variables for java in windows 11
How to Setup Environment Variables for Java in Windows 11 - GeekChamp
May 16, 2026 - Command Prompt can also set permanent environment variables using setx. However, setx has drawbacks: it does not update the current window, and careless use can overwrite or truncate long variables. For most users, the Windows settings method or PowerShell method is safer. ... Close Command Prompt and open a new one before testing. ... setx JAVA_HOME "C:\Program Files\Eclipse Adoptium\jdk-21.0.5.11-hotspot" /M setx Path "%Path%;%JAVA_HOME%\bin" /M
🌐
AEANET
aeanet.org › home › how to set java environment variable in windows 11?
How To Set Java Environment Variable In Windows 11? - AEANET
November 6, 2025 - This tells Windows to look for Java executables in the bin folder of your JDK installation. Click OK to save the changes. ... Open a new command prompt window. Type java -version and press Enter. If the JDK version is displayed, the environment variables have been configured correctly.
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 !

🌐
The Coder World
thecoderworld.com › home › windows › how to set up java environment variables on windows 11
How to Set Up Java Environment Variables on Windows 11 - thecoderworld
January 26, 2026 - Java environment variables tell Windows operating system where Java is installed and how applications should access it. ... Path (Java Path variable) – Allows you to run Java commands and Java-based applications on Windows 11
Find elsewhere
🌐
Position Is Everything
positioniseverything.net › home › how to setup environment variables for java in windows 11
How to Setup Environment Variables for Java in Windows 11 - Position Is Everything
February 24, 2026 - Manually setting CLASSPATH is only necessary for legacy applications or very simple command-line programs. When used incorrectly, it can override expected defaults and cause ClassNotFoundException errors. ... Windows 11 allows environment variables to be defined at both the user and system level.
🌐
GeekChamp
geekchamp.com › home › how to set up environment variables for java in windows 11
How to Set Up Environment Variables for Java in Windows 11 - GeekChamp
December 24, 2025 - Locate the Path variable in System variables and select it. Click Edit and then New. Enter %JAVA_HOME%\bin to include Java’s executable in your system path. Confirm all changes by clicking OK repeatedly. Open Command Prompt and type java -version. Type echo %JAVA_HOME% to ensure the path ...
🌐
Stack Overflow
stackoverflow.com › questions › 73014615 › java-jdk-1-8-0-win-11-system-variables
path - java JDK 1.8.0 Win 11 - system variables - Stack Overflow
I've just istalled JDK8 on PC Windows 11 Home Now im trying to run simple default program from NetBeans14 In environmental variables: PATH : C:\Program Files\Java\jdk1.8.0_202\bin CLASSPATH : C:\Pr...
🌐
TechBloat
techbloat.com › home › how to set environment variable for java in windows 11
How to set environment variable for java in Windows 11 - TechBloat
March 14, 2025 - Setting up environment variables for Java in Windows 11 is a crucial step that enhances the functionality of Java applications on your system. This guide covered all necessary steps to ensure your development environment is set up correctly, from defining JAVA_HOME to configuring the Path variable.
🌐
The Windows Club
thewindowsclub.com › the windows club › general › how to set java_home in windows 11/10
How to set JAVA_HOME in Windows 11/10
Learn how to set JAVA_HOME as the Environment variable in Windows and also how to check or test the JAVA_HOME configuration setup using CMD.
Published   July 13, 2024
🌐
UMA Technology
umatechnology.org › home › how to setup environment variables for java in windows 11
How to Setup Environment Variables for Java in Windows 11 - UMA Technology
May 16, 2026 - In that case, the JDK root folder is everything before \bin\java.exe: C:\Program Files\Eclipse Adoptium\jdk-21.0.5.11-hotspot · The graphical method is the best option for most users. It is easy to review, edit, and fix later. Right-click the Start button. Select System. Scroll down and select ...
🌐
TechBloat
techbloat.com › home › how to setup environment variables for java in windows 11
How to Setup Environment Variables for Java in Windows 11 - TechBloat
December 29, 2024 - Setting up environment variables for Java in Windows 11 is essential for a smooth Java development experience. By correctly configuring the JAVA_HOME, PATH, and CLASSPATH variables, you ensure that Java applications and tools can locate the necessary resources and configurations.
🌐
GeeksforGeeks
geeksforgeeks.org › java › setting-environment-java
Setting up Environment Variables For Java - Complete Guide to Set JAVA_HOME - GeeksforGeeks
May 9, 2025 - Click Windows + S, search for "Environment Variables," and click Edit the system environment variables. In the System Properties window, click Environment Variables. Now, go to Environment Variable > System Variable section > click New.
🌐
Super User
superuser.com › questions › 1784132 › i-have-an-issue-with-printing-paths-from-environment-variables-in-windows-11
java - I have an issue with printing paths from environment variables in windows 11 - Super User
May 15, 2023 - I suspect that is a problem with the environment variables or something. I run java --version and javac --version, it understands it and tells me the version 17 lts and other details. I don't know what to do. ... You are mixing Windows CMD commands with linux/unix bash commands.