6

This appears to be a problem I do not see on linux or Windows machines. I have my environment setup with a JAVA_HOME derived from /usr/libexec/java_home. This is in my .bashrc file:

export JAVA_HOME=$(/usr/libexec/java_home -version 1.7)

which results in:

~/dev/Endeavor/endeavor-sdk$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.7.0_17.jdk/Contents/Home

However when I run Maven on my project, I get an error from the native2ascii plugin:

[ERROR] Failed to execute goal org.codehaus.mojo:native2ascii-maven-plugin:1.0-alpha-2-SNAPSHOT:native2ascii (default) on project dataAccessServices: Error starting Sun's native2ascii: -> [Help 1]

My investigation points to that I am using a JRE instead of a JDK. That's odd since I am clearly pointing to the JDK in my JAVA_HOME variable. However, here is the output of mvn -version:

~/dev/Endeavor/endeavor-sdk$ mvn -version
Apache Maven 3.0.4 (r1232337; 2012-01-17 03:44:56-0500)
Maven home: /usr/share/maven
Java version: 1.7.0_17, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_17.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.7.5", arch: "x86_64", family: "mac"

Notice the "Java home:" line indicates that the ${java.home} variable has been moved to the JRE instead of the JDK that the JAVA_HOME environment variable points to.

I have tried setting the JAVA_HOME in numerous places but I can't seem to find a way to get maven to use the JDK as the home and not the JRE.

UPDATE:

I found this that appears to indicate that this is expected behavior: Java_home in Maven

But that does not explain why the native2ascii plugin cannot find the JDK tool it needs.

I have removed the use of native2ascii since it was largely unnecessary. So, I am avoiding the problem at this point. However, if anyone has an idea as to why this behaves differently on different systems, please let me know.

Community
  • 1
  • 1
AlphaGeek
  • 383
  • 2
  • 11
  • Have you looked at this one: http://stackoverflow.com/questions/3371737/maven-confused-about-jre-been-used – sheidaei Jul 08 '13 at 14:46
  • @sheidaei that is completely unrelated to the issue I am having, thanks. – AlphaGeek Jul 08 '13 at 18:07
  • why don't you try putting your JDK in /Library/Java/JavaVirtualMachines/jdk1.7.0_17.jdk/Contents/Home/jre and then try, if you haven't already? This is not a solution but a workaround. I guess doing this may cause more problems than solving it. – sheidaei Jul 08 '13 at 18:26
  • BTW is your maven versions the same on Mac / Linux / Windows? – sheidaei Jul 08 '13 at 18:26
  • Moving the jdk is not an option. That would create a situation where the normal update process would not work and cannot be repeated on multiple developers' machines consistently. And yes I am using the same version of Maven on Linux and Mac. The Windows users are also using the same version. – AlphaGeek Jul 09 '13 at 13:59
  • Have you seen this? It appears that it would solve your problem. http://stackoverflow.com/questions/16397677/exception-thrown-when-building-ear-after-switching-to-jdk-7 – Brian Chapman Oct 13 '13 at 00:41

2 Answers2

0

Have you tried running mvm help:system that should print all environment variable values that are relevant to maven?

aljipa
  • 716
  • 4
  • 6
0

There has been lots of discussions on this matter and here Java_home in Maven you can find a real good answer. In a nutshell: your configuration it's just right, it is just a matter of semantics. You can read further here: http://javahowto.blogspot.com/2006/05/javahome-vs-javahome.html

Hugo Tavares
  • 314
  • 4
  • 14