我是刚开始学习java编程!我想在 Maven 项目中制作一个 .jar。运行此命令 mvn clean install
后,我收到以下错误消息:
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile(default-compile) on project wps-demo: Compilation failure
Unable to locate the Javac Compiler in:C:\Program Files\Java\jre7..\lib\tools.jar
Please ensure you are using JDK 1.4 or above and not a JRE(the com.sun.tools.javac.Main class is required)
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable
我该怎么做才能清除这个错误!
最佳答案
您似乎只安装了 JRE(Java 运行时环境),而不是 JDK(Java 开发工具包),如以下错误消息所示:
Please ensure you are using JDK 1.4 or above and not a JRE(the com.sun.tools.javac.Main class is required)
Download并从 Oracle 网站安装JDK(不是 JRE)。
JRE 允许您运行 Java 程序,但不包括开发 Java 软件所需的工具,例如 Java 编译器。 JDK 确实包含这些工具。
如果您已经安装了 JDK,请确保 JAVA_HOME
环境变量引用您安装 JDK 的目录,而不是包含 JRE 的目录。
关于java - 失败于 "mvn clean install"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15544663/