英文:
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:
<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>
答案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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论