Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/397.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 尝试调试我的代码时出错_Java - Fatal编程技术网

Java 尝试调试我的代码时出错

Java 尝试调试我的代码时出错,java,Java,当我尝试调试代码时,会出现以下错误: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2 [INFO] ------------------------------------------------------------------------ [ERROR] **Failed to execute goal org.apache.maven.plugins:maven-compiler-*

当我尝试调试代码时,会出现以下错误:

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2

[INFO] ------------------------------------------------------------------------
[ERROR] **Failed to execute goal org.apache.maven.plugins:maven-compiler-**plugin:2.0.2:compile (default-compile) on project napier-am: Compilation failure
Unable to locate the Javac Compiler in:
  C:\Program Files (x86)\Java\jre6\..\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.
-> [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

您的
JAVA\u主页
路径未设置。您需要将其设置为
C:\Program Files\Java\jdk

所有内容都显示在异常中:

在以下位置找不到Java编译器:C:\Program Files(x86)\Java\jre6..\lib\tools.jar

您的maven任务正在尝试“编译”某些内容,但找不到Java编译器(JDK=Java开发工具包)

请确保您使用的是JDK1.4或更高版本,而不是JRE

相反,它会找到一个JRE=Java运行时环境(用于运行Java程序,而不是编译它们)

您可以通过设置Java_HOME环境变量来更改Java安装的位置

您需要安装有效的JDK版本,并且JAVA_HOME环境变量必须指向此JDK文件夹。

Maven使用JAVA_HOME访问JAVA在计算机上的位置。在您的情况下,您可以将其指向JRE而不是JDK。正确设置JAVA_HOME环境变量,它就会工作

如果您只想让Maven使用不同的位置/版本,您可以使用类似这样的方式编辑mvn.bat文件

set JAVA_HOME=<path_to_other_jdk>
set JAVA\u HOME=
是的,谢谢你的提示。。 每个人都是对的。 在我的JDK版本中,tools.jar不可用,这就是为什么我会遇到这个问题,它没有找到tools.jar,而JAVA_HOME Variable配置正确。 只需要关注Tools.jar,以便重新安装java版本(我使用的是java 6) 现在开始project-->检查生成路径并确保-- 点击

已安装的jre 编辑 jre home=C:\Program Files(x86)\Java\jdk1.6.0\u 25


请确保您使用的是JDK 1.4或更高版本,而不是JRE?@Jeet Singh为项目配置构建路径,并将Java库指向JDKMy-Java_HOME-C:\Program Files(x86)\Java\jdk1.6.0\u 25我是Maven的新手。当我尝试构建时,它会显示构建成功,但在调试时会给出上面提到的error@GwynEvans这是我的错误。我相应地编辑了它:)很公平,现在删除了。对于OP来说,使用JRE可以让您运行一些东西,但您需要JDK来编译它们。另外,这不是调试消息,Maven正在尝试编译一些东西,所以不要假设您已经构建了它。是的,谢谢。那是我的错误。现在我可以建造它了