3

I am trying to build a project using Maven but I am always getting this error:

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project languagetool-core: No such compiler 'javac'. -> [Help 1]

I have set %JAVA_HOME% to my JDK (which is JDK7, which I must use because the project requires it).

I am using maven-compiler-plugin version 3.1

MAVEN AND JAVA VERSION

Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T19:37:52+02:
Maven home: D:\apache-maven-3.2.1\bin\..
Java version: 1.7.0_40, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_40\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"

Any ideas about how to solve the problem?

Wolfgang Fahl
  • 15,016
  • 11
  • 93
  • 186
  • 2
    What Java version do you see if you execute `mvn -v`? – matsev Jun 12 '14 at 14:34
  • 1
    Seems your JAVA_HOME is pointing to the JRE not the JDK directory `vendor: Oracle Corporation Java home: C:\Program Files\Java\jdk1.7.0_40\**jre**` – SubOptimal Jun 13 '14 at 07:31

2 Answers2

1

If you can run javac from the command line, there are no problems with your PATH. The most likely cause is that one of your jars used by the maven-compiler-plugin is corrupted.

You can try deleting org/apache/maven/plugins, and/or the org/codehaus/plexus directories from your local .m2 maven repository, forcing maven to re-download them next time you try a build. If this doesn't work for you, you can try a more drastic approach and just delete your whole .m2 repository to make sure you've purged the problematic jar. The plexus jars are the prime suspects however, particularly plexus-compiler-javac which is responsible for providing the javac wrapper to the maven-compiler-plugin.

Dan Cohen
  • 151
  • 3
0

Add %JAVA_HOME%\bin to your PATH environment variable (usually SYSTEM -> Environment Variables -> All Users -> PATH),

PATH=%JAVA_HOME%\bin;%PATH%
Elliott Frisch
  • 198,278
  • 20
  • 158
  • 249