有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java我正在执行我的代码,出现错误“找不到java编译器”

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project wovv-target: Compilation failure
Unable to locate the Javac Compiler in:
C:\Program Files\Java\jdk1.8.0_131\..\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]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

共 (1) 个答案

  1. # 1 楼答案

    Maven试图在错误的目录中找到javac,首先检查JAVA_HOME系统变量。建议我在系统上安装maven,并配置NetBeans以使用它,而不是捆绑maven

    echo $JAVA_HOME
    C:\Progra~1\Java\jdk1.8.0_131
    

    之后,通过mvn-v命令检查maven的安装

     mvn -v
    Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-03T22:39:06+03:00)
    Maven home: C:\Program Files\apache-maven-3.5.0
    Java version: 1.8.0_131, vendor: Oracle Corporation
    Java home: C:\Progra~1\Java\jdk1.8.0_131\jre
    Default locale: ru_RU, platform encoding: Cp1251
    OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
    

    另外,如果你使用cmd标准win控制台替换$to%,我使用的是bash

     echo %JAVA_HOME%
    

    还要让NetBeans像这样使用系统安装的maven:

    enter image description here