what is the reason for the existence of the JAVA_HOME environment variable?
java_home vs path
check your android_sdk_root / java_home / path environment variables
warning: java_home environment variable is not set
java_home environment variable is not defined correctly
failed to find java_home' environment variable
what is java_home
java_home environment variable configured correctly
Many java based application requires to set JAVA_HOME env variable. What's the purpose of this variable?
Environment variables are strings that contain information such as drive, path, or file name.
The JAVA_HOME environment variable points to the directory where the Java runtime environment (JRE) is installed on your computer.
java, Many java based application requires to set JAVA_HOME env variable. What's the purpose of this variable? Solution Environment variables are strings that The JAVA_HOME environment variable must point to the root of the installation folder of a JDK. It cannot point to a sub-directory of the JDK, and it cannot point to a parent directory that contains the JDK. It must point directly at the JDK installation directory itself.
The purpose is to point to where Java is installed.
$JAVA_HOME/bin/java should execute the Java runtime.
What is JAVA_HOME? - Definition from WhatIs.com, JAVA_HOME is an operating system environment variable that directs a user to the file A Java installation exists but JAVA_HOME has been set incorrectly It's a reasonably common convention in wrapper scripts. Many wrapper scripts will follow symlinks from which java to figure out JAVA_HOME if they need it, but not all of them. The JVM internally exposes the equivalent as the java.home system property internally, but doesn't care about JAVA_HOME itself.
When you run a Java program you need to first start the JVM, typically this is done by running an executable, on Windows this is java.exe. You can get that in lots of ways for example just giving a full path:
or may having it on your PATH.
You specify as command line arguments some class files or Jar files containing class files which are your program. But that's not enough, the java.exe itself needs various other resources, not least all the Java libraries. By setting the environment variable JAVA_HOME you specify where the JRE, and hence all those runtime resources, are to be found. You should ensure that the particular Java you execute matches the setting of JAVA_HOME.
You may also need to put
JAVA_HOME\bin early on your path so that if the
java.exe spawns a copy of itself (for example to compile a JSP) it picks up the right version.
What is the use of JAVA_HOME?, The JAVA_HOME environment variable points to the directory where the Java runtime environment (JRE) or Java Development Kit (JDK) is installed on your Installing the JDK Software and Setting JAVA_HOME. If you do not already have the JDK software installed or if the JAVA_HOME environment variable is not set, the GlassFish ESB installation will not be successful. The following tasks provide the information you need to install the JDK software and set JAVA_HOME on UNIX or Windows systems.
Mastering AspectJ: Aspect-Oriented Programming in Java, exist "%JAVA_HOME%\bin\java" goto haveJava echo java does not exist as %JAVA_HOME%\bin\java echo please fix the JAVA_HOME environment variable Installing the JDK Software and Setting JAVA_HOME If you do not already have the JDK software installed or if JAVA_HOME is not set, the GlassFish ESB installation will not be successful. The following tasks provide the information you need to install the JDK software and set JAVA_HOME on UNIX or Windows systems.
According to @dirai here
JAVA_HOME is not used by Java itself but by some third party tools like for instance Apache Tomcat. Most applications however will work without this variable being set but some could show unexpected behaviour.
Configuring the JAVA_HOME and JRE_HOME Environment , If these environment variables do not exist, add them to the list. For whatever reason, my tomcat instance wasn't set to "Use Default" and not updating this path Why Oracle did such a poor way to point to java is beyond me I guess the reason was that when you have relatively constant env var (pointing always to the one place - f.e. javapath folder), you can change paths dynamically, on on the fly (changing a link does not require shell restart).
Web Data Management, We give a few examples of Java programs that connect to EXIST, access documents, You need a Java programming environment (Java Development Kit) with the and JAVA_HOME/bin directory added to the PATH environment variable. Suppose you have install JDK 10 after JDK 8 and in the system environment variable set path like "C:\ProgramData\Oracle\Java\javapath" then Java version control by this path. it will ignore JAVA_HOME even jdk 1.8 path set here So remove "C:\ProgramData\Oracle\Java\javapath" in path to get effect of JAVA_HOME path
What is PATH and CLASSPATH in Java, The PATH and CLASSPATH are two most important environment variables of Java in Java programming language due to two reasons; first because in most of even if that class also exists in another directory which exists in CLASSPATH. After you've installed Java in Windows, you must set the JAVA_HOME environment variable to point to the Java installation directory. This information is only relevant if you're installing Confluence manually on a Windows server. If you're using the installer we'll do this part for you.
- you can read here
- I find the question has not an answer yet. As to execute java itself, it's not necessary to have this variable if you have the folder with the binary in the path. All answers point out the obvious: "Where java was installed". But Why: what is the meaning to running java applications?
- despite all these comments and answers, I see no actual reason to set this environment variable. No rationale. I came here from trying to set this with wsdl2java. If I wasn't using this tool, no need for the env variable....seemingly it's just that some tools use this var. but why?
- @Thufir - I have not seen the reason stated anywhere explicitly, however. - JAVA_HOME is just convention. It doesn't have any special meaning other than everyone agreed to use it AFAIK - The only use I see is it gives tools the ability to differentiate between the JRE which is normally set in the PATH variable and the JDK. Normally the JAVE_HOME is set to the JDK. - It's explicit. There is no dealing with the order of directories like you have with PATH where there could be multiple places to find java exe.
- One correction: JAVA_HOME should point to a JDK not a JRE. Many apps don't care about the difference but it is significant for some.
- There is also JRE folder available in the JDK. Hence, with the help of JAVA_HOME , an application can locate JDK as well as JRE.
- @ChrisNava: Seem that pointing JAVA_HOME to a JRE installation is valid in some cases (most non-development cases I would guess): stackoverflow.com/questions/17601827/…. So saying "should" is saying too much.
- But it is stupid, because java should be in the path, and the binary can locate itself and open the other files using a relative path.
- It's useful when java is not on $PATH, for example when you have multiple SDK installations.
- The 1st argument to the binary is the full name of the executable itself, java doesn't need to be in the path to find its own directory.
- @Haakon As someone trying to set up multiple JDKs, why would you not want java on the path? How does Windows locate java from java_home anyway? I thought the path was more or less defined as "the list of places the OS will look for executables".
- You are conflating
path, which are different things but used in Windows exactly the same way as in Linux.
- @val just pointing out, that has since been corrected in his answer.
- Just to add to the list JAVA_HOME in Windows 10