执行maven时无法找到Java classes.jar'错误

时间:2016-02-24 16:07:58

标签: java macos maven

我刚在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)

任何想法?

2 个答案:

答案 0 :(得分:1)

对于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部分,现在它正在运行。

答案 1 :(得分:0)

传递类

java.net.MalformedURLException: no protocol: /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Classes/classes.jar

我猜它的'JavaVM.framework'或者像'file:'

这样的协议真的很糟糕

如果您在JavaVM.framework之类的路径中安装了JDK,请尝试在没有'。'的情况下安装在另一个路径中。