Difference between java.home and JAVA_HOME

In my java code, I have this line System.getProperty("java.home"). In some environments, this returns the same value as the value JAVA_HOMEas an environment variable.

But in some environments it System.getProperty("java.home")returns a completely different value from JAVA_HOME.

So my question is, what is the difference between java.homeand JAVA_HOMEin terms of java?

What I know from my research is the JAVA_HOMEinstallation path of jdk, java.homethis is the installation path of jre, but then why can't it match, since jre can be part of the jdk installation.

+4
source share
2 answers

, JAVA_HOME JDK, (% JAVA_HOME%).

java.home JRE, JRE, , , JRE JDK /

, , jre jdk .

, , :

%JAVA_HOME% = C:\Program Files\Java\jdk1.6.0_24

jre:

"C:\Program Files (x86)\Java\jre1.8.0_73\bin\java" -jar TheJavaFile.jar

java.home JAVA_HOME

, , .

, , , JRE - , JDK, ,

, JDK JRE, :

enter image description here

JDK JRE , JRE, , , . JRE , Java Machine (JVM) Java.

+1

Oracle java.home - , Java Runtime Environment, JAVA_HOME - - . . , , .

, JAVA_HOME.

+2

Source: https://habr.com/ru/post/1682767/


All Articles