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
🌐
Atlassian
confluence.atlassian.com › doc › setting-the-java_home-variable-in-windows-8895.html
Setting the JAVA_HOME Variable in Windows | Confluence Data Center 10.2 | Atlassian Documentation
Set the value of the environment variable to your JDK (or JRE) installation path as follows: setx /m JAVA_HOME "C:\Program Files\Java\jdk11.0.17.8"
Discussions

I get "JAVA_HOME is not set" error even though it exists in System Environment Variables
First things first. Don't worry about uninstalling IntelliJ/Eclipse/whatever. You don't need to do that 🙂 (though you might have needed to close your development environment (intelliJ) down and reopen it for it to become "aware" of your new JAVA_HOME variable. Not sure on that one though. But that leads me to my main answer to your question. I'm wondering if it could be the terminal window you're in that's the problem. I just want to check, are you using a terminal within IntelliJ? Or both IntelliJ and a separate terminal application like 'terminal', 'git bash', 'powershell', etc? If you're using a separate terminal and haven't opened a new window since you set JAVA_HOME, that terminal window will not be "aware" that you've set a new JAVA_HOME variable. I've encountered this, myself, before. More on reddit.com
🌐 r/javahelp
11
2
December 20, 2024
How do I set JAVA_HOME ?
Java home basically is the full directory where your java exe and other related stuff is present. Your OS/windows doesnt know what or where java.exe is. So you need to tell it that hey, this is where you should look for java stuff. The OS use something known as an Environment Variable to store these things. Under Environment variables there are many default ones, “path” variable is where the OS looks for an exe when you type some command. There can be multiple paths/folders in the path variable, just add your full directory of where you extracted/installed java java/bin to that variable. You can similarly also create new environment variables, create a new variable JAVA_HOME and set the path to the location of the java folder More on reddit.com
🌐 r/IntelliJIDEA
7
3
October 22, 2024
🌐
Specinnovations
help.specinnovations.com › configuring-java-home-on-windows
Configuring JAVA_HOME Environment Variable on Windows
In the New System Variable dialog, enter JAVA_HOME as the Variable name. Paste the copied JDK path (e.g., C:\Program Files\Java\jdk-17) into the Variable value field. ... Click OK to close the Edit or New System Variable dialog. Click OK again to close the Environment Variables dialog, and then OK to close the System Properties window.
🌐
Oracle
docs.oracle.com › cd › E19182-01 › 821-0917 › inst_jdk_javahome_t › index.html
Installing the JDK Software and Setting JAVA_HOME (Using the GlassFish ESB Installation GUI)
On the Advanced tab, select Environment Variables, and then edit JAVA_HOME to point to where the JDK software is located, for example, C:\Program Files\Java\jdk1.6.0_02.
🌐
Medium
medium.com › @zorozeri › setting-up-java-home-5abae0118bfe
Setting up JAVA_HOME. Guideline for Windows, MacOS, and… | by Ahmad Azeri Chandra Bhuana | Medium
November 13, 2024 - JAVA_HOME is exist on your Windows Path environment now. Note : you can also modify the Path on “System variables” instead of “User variables for [your user]”. This way, your JAVA_HOME will be used by all of the User on your Computer.
Find elsewhere
🌐
TheServerSide
theserverside.com › feature › How-to-set-JAVA_HOME-in-Windows-and-echo-the-result
How to set JAVA_HOME in Windows | TheServerSide
Click on the Environment Variables button. Click on the New button under System Variables. Set JAVA_HOME as the environment variable name.
🌐
Delft Stack
delftstack.com › home › howto › java › set java_home in java
How to Set JAVA_HOME Variable in Java | Delft Stack
February 2, 2024 - The Java_Home is a reference variable that refers to the location of Java Runtime Environment and Java Development Kit, also called JDK.
🌐
Atlassian
confluence.atlassian.com › spaces › CONF720 › pages › 1168862563 › Setting+the+JAVA_HOME+Variable+in+Windows
Setting the JAVA_HOME Variable in Windows | Atlassian Support | Atlassian Documentation
Click the Environment Variables button. Under System Variables, click New. ... In the Variable Value field, enter your JDK or JRE installation path . If the path contains spaces, use the shortened path name. For example, C:\Progra~1\Java\jdk1.8.0_65
🌐
Broadcom
ftpdocs.broadcom.com › cadocs › 0 › CA Plex Version 7 0-JPN › Bookshelf_Files › HTML › Plex--Getting Started Guide › 1553066.html
Define the JAVA_HOME environment variable
The JAVA_HOME environment variable determines the Java compiler (Javac.exe) that will be used for Plex Java builds. Plex does not automatically set this environment variable which provides you with the flexibility to switch between different versions of the compiler.
🌐
Scaler
scaler.com › home › topics › how to set java_home?
How to set JAVA_HOME? - Scaler Topics
May 4, 2023 - Click on the Environment Variables button. Select the New button under System Variables. Set JAVA_HOME as the environment variable name.
🌐
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 - Step 3: In the system, variables click the New button. Now in the edit System variable, type variable name as JAVA_HOME and variable path as the path where the JDK folder is saved and click on OK button Usually the path of ...
🌐
Reddit
reddit.com › r/javahelp › i get "java_home is not set" error even though it exists in system environment variables
r/javahelp on Reddit: I get "JAVA_HOME is not set" error even though it exists in System Environment Variables
December 20, 2024 -

I am following this tutorial for making a minecraft mod using IntelliJ and when i get to the point where you type

./gradlew genSources

into the terminal (at about 12:08) i always get

ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

I have tried deleting and reinstalling both Eclipse Adoptium and IntelliJ as well as going into the System Environment Variables and deleting the JAVA_HOME variable and creating it again with this file path: C:\Program Files\Eclipse Adoptium\jdk-21.0.5.11-hotspot, I have also edited the Path system variable to include %JAVA_HOME%\bin and so far I have experienced no change. I don't know much about programming or java but as far as I know your JAVA_HOME is supposed to be linked to a JDK, and as far as I can tell mine is so I don't know whats the problem

🌐
Reddit
reddit.com › r/intellijidea › how do i set java_home ?
r/IntelliJIDEA on Reddit: How do I set JAVA_HOME ?
October 22, 2024 -

Hello! I'm very (very) new to programming. I'm following a tutorial by Kaupenjoe to make (what I thought would be) a very simple Minecraft mod. But when I get to the step in the tutorial at 12:30 and run the terminal command ./gradlew genIntellijRuns, I receive the following error message. I'm still trying to figure out how all of this works, so pardon my ignorance if this is a stupid question, but I cannot for the life of me find how to correct this error. Could anyone walk me through it, please?

ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the location of your Java installation.

🌐
Oracle
docs.oracle.com › cd › E19681-01 › 820-5019 › ghhls › index.html
Setting Your JAVA_HOME and PATH Environment Variables (Sun OpenSSO Enterprise 8.0 Upgrade Guide)
The upgrade scripts and jar command require JDK 1.5 or later. Therefore, set your JAVA_HOME environment variable to point to an installed JDK version 1.5 or later. Additionally, set your PATH environment variable.
🌐
GeeksforGeeks
geeksforgeeks.org › java › setting-environment-java
Setting up Environment Variables For Java - Complete Guide to Set JAVA_HOME - GeeksforGeeks
May 9, 2025 - To set Java Environment Variables, you need to set, JAVA_HOME: It points to the directory where the JDK is installed on the system.
🌐
Highbyte
support.highbyte.com › kb › administration › infrastructure › configure-java-home-and-update-system-path-for-jre
Configure JAVA_HOME and update System Path for JRE
March 23, 2026 - In the Environment Variables window, under the System variables section, click New. Enter JAVA_HOME as the variable name.
🌐
Baeldung
baeldung.com › home › java › core java › java_home vs path environment variables
JAVA_HOME vs PATH Environment Variables | Baeldung
January 8, 2024 - 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.
🌐
Ossez
track.ossez.com › articles › OSS-A-62622027 › Setting-the-JAVAHOME-Variable-in-Windows
Setting the JAVA_HOME Variable in Windows
{{ (>_<) }} This version of your browser is not supported. Try upgrading to the latest stable version. Something went seriously wrong