Reputation: 5475
When I type mvn --version in ubuntu from the terminal(ubuntu),I get the below output.
Warning: JAVA_HOME environment variable is not set.
Apache Maven 3.0.5
Maven home: /usr/share/maven
Java version: 1.7.0_79, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre
Default locale: en_IN, platform encoding: UTF-8
OS name: "linux", version: "3.13.0-32-generic", arch: "amd64", family: "unix"
When I did not set any JAVA_HOME environment variable , how is maven getting the java home installed path.Is it trying to find this path from the /usr/bin/java command which is installed in my system and if so why is it taking the path till jre.
P.S : Also I could not find any java path in any maven config.
Thanks.
Upvotes: 6
Views: 18229
Reputation: 15070
As showed in the CLIReportingUtils.java
(the maven class that retrieves the Java Home), the value comes from the following call :
System.getProperty( "java.home", "<unknown java home>" )
The java.home
is for the JRE unlike the JAVA_HOME
which is for the JDK.
So Maven is displaying the JRE home.
Upvotes: 3
Reputation: 3736
I would say there is a difference between JAVA_HOME
environment variable and the output Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre
.
The latter is just the output of the installation directory see here.
So maven will run Java in background and java knows where its installed.
Upvotes: 1
Reputation: 5475
I think,I understand it now.In the maven script i.e (usr/share/maven/bin/mvn) they are trying to find the java installed using a variety of options.
So at one place they are doing the below
JAVACMD="`which java`"
And now in my system "which java" points to the below
java -> /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
Hope this is how its getting the java path.
Upvotes: 0