[ 
https://issues.apache.org/jira/browse/MNG-5756?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16466521#comment-16466521
 ] 

ASF GitHub Bot commented on MNG-5756:
-------------------------------------

pono closed pull request #117: [MNG-5756] Java home output in mvn -v is 
misleading
URL: https://github.com/apache/maven/pull/117
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java 
b/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java
index 52f2053833..d7e66e0e6a 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java
@@ -68,7 +68,10 @@ public static String showVersion()
         version.append( "Java version: " ).append(
             System.getProperty( "java.version", "<unknown Java version>" ) 
).append( ", vendor: " ).append(
             System.getProperty( "java.vendor", "<unknown vendor>" ) ).append( 
ls );
-        version.append( "Java home: " ).append( System.getProperty( 
"java.home", "<unknown Java home>" ) ).append( ls );
+        String javaHome = System.getenv( "JAVA_HOME" );
+        javaHome = ( javaHome == null ? "<unknown Java home>" : javaHome );
+        version.append( "Java home: " ).append( javaHome ).append( ls );
+        version.append( "JRE used: " ).append( System.getProperty( 
"java.home", "<unknown JRE>" ) ).append( ls );
         version.append( "Default locale: " ).append( Locale.getDefault() 
).append( ", platform encoding: " ).append(
             System.getProperty( "file.encoding", "<unknown encoding>" ) 
).append( ls );
         version.append( "OS name: \"" ).append( Os.OS_NAME ).append( "\", 
version: \"" ).append( Os.OS_VERSION ).append(


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Java home output in mvn -v is misleading
> ----------------------------------------
>
>                 Key: MNG-5756
>                 URL: https://issues.apache.org/jira/browse/MNG-5756
>             Project: Maven
>          Issue Type: Improvement
>          Components: Command Line
>    Affects Versions: 3.2.5, 3.3.3
>         Environment: any
>            Reporter: Jarkko Rantavuori
>            Assignee: Michael Osipov
>            Priority: Minor
>             Fix For: 3.5.4
>
>
> For example on my windows box, mvn -v prints the following:
> {code}
> Java home: C:\Program Files (x86)\Java\jdk1.7.0_51\jre
> {code}
> But my JAVA_HOME is actually
> {code}
> > echo %JAVA_HOME%
> C:\Program Files (x86)\Java\jdk1.7.0_51
> {code}
> In the source code, the line comes from:
> https://git-wip-us.apache.org/repos/asf?p=maven.git;a=blob;f=maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java#l63
> {code}
> version.append( "Java home: " ).append( System.getProperty( "java.home", 
> "<unknown java home>" ) ).append( ls );
> {code}
> which is using property "java.home" to fetch java home. However, "java.home" 
> property is not JAVA_HOME! This is explained in detail in here: 
> http://javahowto.blogspot.fi/2006/05/javahome-vs-javahome.html
> To quote:
> {quote}
>     What's the difference between JAVA_HOME and java.home?
>     JAVA_HOME is the JDK install directory, e.g., C:\jdk5. It's meant to be 
> set as an environment variable and referenced in Windows batch files or Unix 
> scripts. I always have it in my Windows Control Panel and .tcsh files,along 
> with other common environment variables. Some Java applications use the name 
> jdk.home for this purpose, which I think is a better name. But JAVA_HOME has 
> been used since the beginning and is now a convention.
>     java.home is the JRE install directory, e.g., C:\jdk5\jre, or C:\Program 
> Files\Java\jre1.5.0_06. Unlike JAVA_HOME, I never seen java.home as an 
> environment variable. java.home is a build-in Java system property, whose 
> value is the JRE install directory. Since all Java system properties are also 
> exposed as Ant build properties, you can also use $&lcub;java.home&rcub; in 
> build files.
>     Would jre.home be a better name? Maybe, but I don't think Sun will change 
> it.
> {quote}
> This is a source of constant confusion. Some stackoverflow threads to 
> illustrate:
> http://stackoverflow.com/questions/15279586/java-home-in-maven
> http://stackoverflow.com/questions/17620531/maven-pointing-to-jre-instead-of-jdk
> The correct way to print JAVA_HOME would be to use 
> System.getenv("JAVA_HOME"). Either that should be used or current output 
> should be changed so it wouldn't be so misleading.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to