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.
PS : Also I could not find any java path in any maven config.
Thanks.
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.
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.
I think,I understand it now.In the maven script ie (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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.