我刚刚在Mac El Captain上安装了Java 8和Maven。我已经正确设置了所有环境变量,并且java -version确实显示了Java版本。但是,当我尝试从终端运行Maven时,出现以下错误:
File or url '/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Classes/classes.jar' could not be found
java.net.MalformedURLException: no protocol: /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Classes/classes.jar
at java.net.URL.<init>(URL.java:593)
at java.net.URL.<init>(URL.java:490)
at java.net.URL.<init>(URL.java:439)
at com.werken.forehead.Forehead.loadFileOrUrl(Forehead.java:403)
at com.werken.forehead.Forehead.load(Forehead.java:322)
at com.werken.forehead.Forehead.config(Forehead.java:245)
at com.werken.forehead.Forehead.config(Forehead.java:131)
at com.werken.forehead.Forehead.main(Forehead.java:579)
有任何想法吗?
最佳答案
对于Maven 1.x,我发现bin/maven
shell脚本的以下位在Mac上对我造成了相同的错误:
if $darwin; then
TOOLS_JAR="/System/Library/Frameworks/JavaVM.framework/Versions/${JAVA_VERSION}/Classes/classes.jar"
fi
我只是编辑了
bin/maven
脚本文件,并注释了if $darwin; then ... fi
部分,它现在可以工作了。