Unable to set mvn JAVA_HOME setting.

huangapple go评论38阅读模式
英文:

Unable to set mvn JAVA_HOME setting

问题

ls -l /Library/Java/JavaVirtualMachines/
drwxr-xr-x  3 root  wheel  96 Jun 15 14:30 jdk-11.0.7.jdk
drwxr-xr-x  3 root  wheel  96 Jul 15 16:59 jdk1.8.0_261.jdk

# Tell maven to use explicit jdk
$ JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_261.jdk/Contents/Home/ mvn -version

# Despite explicitly setting JAVA_HOME, mvn is still using JDK11
-bash: /Library/Java/JavaVirtualMachines/jdk1.8.0_261.jdk/Contents/Home/: is a directory
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /usr/local/Cellar/maven/3.6.3_1/libexec
Java version: 11.0.7, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-11.0.7.jdk/Contents/Home

I've also tried setting JAVA_HOME manually with:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_261.jdk/Contents/Home

for some reason mvn insists on using jdk 11. Do you know where it might be overridden?

My pom.xml:

<plugins>
  <plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>${mvn-compiler.version}</version>
    <configuration>
      <source>1.8</source>
      <target>1.8</target>
      <compilerArgument>-Xlint:all</compilerArgument>
      <debug>true</debug>
      <debuglevel>lines,vars,source</debuglevel>
    </configuration>
  </plugin>
</plugins>
英文:
ls -l /Library/Java/JavaVirtualMachines/
drwxr-xr-x  3 root  wheel  96 Jun 15 14:30 jdk-11.0.7.jdk
drwxr-xr-x  3 root  wheel  96 Jul 15 16:59 jdk1.8.0_261.jdk

# Tell maven to use explicit jdk
$ JAVA_HOME=`/Library/Java/JavaVirtualMachines/jdk1.8.0_261.jdk/Contents/Home/` mvn -version

# Despite explicitly setting JAVA_HOME, mvn is still using JDK11
-bash: /Library/Java/JavaVirtualMachines/jdk1.8.0_261.jdk/Contents/Home/: is a directory
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /usr/local/Cellar/maven/3.6.3_1/libexec
Java version: 11.0.7, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-11.0.7.jdk/Contents/Home

I've also tried setting JAVA_HOME manually with:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_261.jdk/Contents/Home

for some reason mvn insists on using jdk 11. Do you know where it might be overridden?

My pom.xml:

&lt;plugins&gt;
  &lt;plugin&gt;
    &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
    &lt;version&gt;${mvn-compiler.version}&lt;/version&gt;
    &lt;configuration&gt;
      &lt;source&gt;1.8&lt;/source&gt;
      &lt;target&gt;1.8&lt;/target&gt;
      &lt;compilerArgument&gt;-Xlint:all&lt;/compilerArgument&gt;
      &lt;debug&gt;true&lt;/debug&gt;
      &lt;debuglevel&gt;lines,vars,source&lt;/debuglevel&gt;
    &lt;/configuration&gt;
  &lt;/plugin&gt;
&lt;/plugins&gt;

答案1

得分: 3

您的JAVA_HOME导出命令不正确。

您的bash消息也在说同样的事情。您使用了反引号,您需要使用单引号或双引号。

正确的语句应该是

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_261.jdk/Contents/Home/ mvn --version
英文:

Your JAVA_HOME exporting command is incorrect.

Your bash message also saying the same thing. You used back tick you need to use single quote or double quote

Correct statement would be

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_261.jdk/Contents/Home/ mvn --version

huangapple
  • 本文由 发表于 2020年8月3日 00:00:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/63218145.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定