Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does maven know JAVA_HOME set as an environment variable inUbuntu

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.

like image 386
crackerplace Avatar asked Sep 27 '22 10:09

crackerplace


1 Answers

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.

like image 144
Zakaria Avatar answered Oct 13 '22 00:10

Zakaria