If you're doing any sort of development, or building with Maven or Ant, you need to point to the JDK (Java Development Kit) where utilities such as javac (the Java Compiler) reside. Otherwise, you can point to the JRE (Java Runtime Environment).
The JDK contains everything the JRE has and more. If you're just executing Java programs, you can point to either the JRE or the JDK.
Answer from David W. on Stack OverflowIf you're doing any sort of development, or building with Maven or Ant, you need to point to the JDK (Java Development Kit) where utilities such as javac (the Java Compiler) reside. Otherwise, you can point to the JRE (Java Runtime Environment).
The JDK contains everything the JRE has and more. If you're just executing Java programs, you can point to either the JRE or the JDK.
Simply (change to your jdk1.x.x.x_xx)
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_05
How do I set JAVA_HOME ?
java - What is JAVA_HOME? How does the JVM find the javac path stored in JAVA_HOME? - Stack Overflow
Setting JAVA_HOME path
I get "JAVA_HOME is not set" error even though it exists in System Environment Variables
Videos
You can set your JAVA_HOME in /etc/profile as Petronilla Escarabajo suggests. But the preferred location for JAVA_HOME or any system variable is /etc/environment.
Open /etc/environment in any text editor like nano or gedit and add the following line:
JAVA_HOME="/usr/lib/jvm/open-jdk"
(java path could be different)
Use source to load the variables, by running this command:
source /etc/environment
Then check the variable, by running this command:
echo $JAVA_HOME
Update
Usually most linux systems source /etc/environment by default. If your system doesn't do that add the following line to ~/.bashrc (Thanks @pje)
source /etc/environment
To set JAVA_HOME environment variable, do the following:
- Launch Terminal by pressing Ctrl+Alt+T on your keyboard.
- Enter the following command:
$gksudo gedit /etc/environment - Depending on where you installed your Java, you will need to provide the full path. For this example, I installed Oracle JDK 7 in the
/usr/lib/jvm/java-7-oracledirectory.
Scroll to the end of the file and enter the following:
JAVA_HOME=/usr/lib/jvm/java-7-oracle
export JAVA_HOME - Save your file and exit gedit.
- Lastly, reload the system PATH with the following command:
$. /etc/environment
The above method will save you the hassle in having to run the commands every time you log in to your computer.
I need help finding the location of my java_home/bin
"Start" > "Control Panel" > "Java".
Select "Java" tab.

Click "View"
Look in the "Path" column for version of the JRE you have installed.

In the above example the "Path" contains:
C:\apps\jdk\jre\bin\javaw.exe
JAVA_HOME should point to the root directory of the Java installation,
so in this case:
C:\apps\jdk
And the PATH should contain JAVA_HOME\bin, in this case:
C:\apps\jdk\bin
From a command prompt we can set these values using the following commands:
setx JAVA_HOME C:\apps\jdk
setx PATH C:\apps\jdk\bin;%PATH%
Notes:
- Modify the above commands as appropriate for your Java installation.
- These are
SystemnotUserenvironment variables.
See Installing the JDK Software and Setting JAVA_HOME and PATH and CLASSPATH for more information.
On your keyboard click the windows key and q and search java. Then in the apps section next to about java click the arrow and click open file location. You are here at the file location
If this does not work for you you maybe don't have windows or you have an old version of it or if you have windows and the latest version of windows then I don't know what is wrong.
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.
JVM does not find java.exe. It doesn't even call it. java.exe is called by the operating system (Windows in this case).
JAVA_HOME is just a convention, usually used by Tomcat, other Java EE app servers and build tools such as Gradle to find where Java lives.
The important thing from your point of view is that the Java /bin directory be on your PATH so Windows can find the .exe tools that ship with the JDK: javac.exe, java.exe, jar.exe, etc.
JAVA_HOME and JRE_HOME are not used by Java itself. Some third-party programs (for example Apache Tomcat) expect one of these environment variables to be set to the installation directory of the JDK or JRE. If you are not using software that requires them, you do not need to set JAVA_HOME and JRE_HOME.
PATH is an environment variable used by the operating system (Windows, Mac OS X, Linux) where it will look for native executable programs to run. You should add the bin subdirectory of your JDK installation directory to the PATH, so that you can use the javac and java commands and other JDK tools in a command prompt window. Courtesy: coderanch