macos – maven build时出现JAVA_HOME错误,OSX-10.8.4版本
作者:互联网
Error: JAVA_HOME is not defined correctly.
We cannot execute
/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home/bin/java
我已将OSX升级到10.8.4.在OSX升级之后,我已将JDK和JRE升级到7.但是当我尝试maven构建项目时,我收到了上述错误.
当我运行ls -al /System/Library/Frameworks/JavaVM.framework/Versions/
我收到以下回复
drwxr-xr-x 11 root wheel 374 Jul 22 22:33 .
drwxr-xr-x 10 root wheel 340 Jul 22 18:30 ..
lrwxr-xr-x 1 root wheel 10 Jul 22 18:30 1.4 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10 Jul 22 18:30 1.4.2 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10 Jul 22 18:30 1.5 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10 Jul 22 18:30 1.5.0 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10 Jul 22 18:30 1.6 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10 Jul 22 18:30 1.6.0 -> CurrentJDK
drwxr-xr-x 7 root wheel 238 Jul 22 18:30 A
lrwxr-xr-x 1 root wheel 1 Jul 22 18:30 Current -> A
lrwxr-xr-x 1 root wheel 59 Jul 22 18:30 CurrentJDK -> /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents
对于这个ls -al /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home/bin
我没有进一步看到CurrentJDK中的任何内容.
在运行/usr/libexec / java_home时
我明白了:
/Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home
我对使用OS X非常陌生.请告诉我,如果我仍然错过了使其成功的任何一点.
解决方法:
Apple建议将JAVA_HOME设置为“/usr/libexec / java_home”.
对我有用的是围绕$()包装.所以我最终使用以下命令配置JAVA_HOME,如$(/usr/libexec / java_home):
vim ~/.bash_profile
export JAVA_HOME=$(/usr/libexec/java_home)
source ~/.bash_profile
标签:java,macos,mountain-lion 来源: https://codeday.me/bug/20190817/1677472.html