Java MacOSX 10.9.2上的Maven 3.2.1错误地使用了JRE 7,而不是JDK 7

Java MacOSX 10.9.2上的Maven 3.2.1错误地使用了JRE 7,而不是JDK 7,java,macos,maven,osx-mavericks,Java,Macos,Maven,Osx Mavericks,我已尝试按照上的说明进行操作,但它们无法解决我的问题:-( 当我跑步时: mvn clean install mvn clean install -X 我得到以下问题: [INFO] Scanning for projects... [INFO] [INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread cou

我已尝试按照上的说明进行操作,但它们无法解决我的问题:-(

当我跑步时:

mvn clean install
mvn clean install -X
我得到以下问题:

[INFO] Scanning for projects...
[INFO] 
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building JBehave JUnit Runner 1.2.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ jbehave-junit-runner ---
[INFO] Deleting /Users/skurlow/IdeaProjects/mygithubforks/jbehave-junit-runner/target
[INFO] 
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ jbehave-junit-runner ---
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ jbehave-junit-runner ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/skurlow/IdeaProjects/mygithubforks/jbehave-junit-runner/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ jbehave-junit-runner ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 5 source files to /Users/skurlow/IdeaProjects/mygithubforks/jbehave-junit-runner/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.164 s
[INFO] Finished at: 2014-04-18T07:25:53+10:00
[INFO] Final Memory: 11M/126M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project jbehave-junit-runner: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
我已经安装了Oracle的JDK7:

echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home
我添加到pom.xml中是因为maven决定使用1.5而不是1.7的源和目标:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
我看到它告诉我JRE正在被使用,而不是JDK。但我不能改变maven使用JDK而不是JRE-(

运行的输出:

mvn --version
javac -version
是:

运行的输出:

mvn --version
javac -version
是:


我在windows环境中也遇到过同样的错误。解决方案是将JAVA_HOME环境变量设置为JDK路径,而不是JRE路径。 这是:

JAVA\u HOME=C:\Program Files\JAVA\jdk1.7.0\u 55

路径=%JAVA\u HOME%\bin

请确保遵循针对OSX的maven安装说明。对于您来说,这可能是:


确保JAVA_HOME设置为JDK的位置,例如export JAVA_HOME=/usr/JAVA/jdk1.7.0_51,并且$JAVA_HOME/bin位于PATH环境变量中。

修复方法是从~/Library/JAVA/Extensions中的我的主目录中删除tools.jar

不知什么原因,我有一个JDK5版本的它躺在那里


如果您将其放在/Library/Java/Extensions的根文件夹中,您也可以检查并删除它。将上面发布的
mvn--version
编辑的输出包括您想要的输出
javac-version
?上面编辑的发布包括
javac-version
信息
javac 1.7.0_55