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

22,819

Solution 1

You compile your code for java 1.3 and use generics, which was introduced in java 1.5. You have to change to java 1.5 or higher.

   <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
            <source>1.7</source>
            <target>1.7</target>
        </configuration>
    </plugin>

Solution 2

You may want to use a higher JDK-("Java"-) Version for the compiler plugin like:

<plugin>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>3.2</version>
      <configuration>
        <source>1.7</source>
        <target>1.7</target>
        <showWarnings>true</showWarnings>
        <showDeprecation>true</showDeprecation>
      </configuration>
    </plugin>

Solution 3

Your Maven is reading Java version as 1.6.0_65, Where as the pom.xml says the version is 1.7.

Try installing the required verison.

If already installed check your $JAVA_HOME environment variable, it should contain the path of Java JDK 7. If you don't find it, fix your environment variable.

also remove the lines:

 <fork>true</fork>
 <executable>${JAVA_1_7_HOME}/bin/javac</executable>

from the pom.xml

Share:
22,819
panwar001
Author by

panwar001

Technology Enthusiast, Focused on Logics and Basics.

Updated on July 09, 2022

Comments

  • panwar001
    panwar001 almost 2 years
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project mrlda: Compilation failure: Compilation failure:
    
    [ERROR] /home/panwar/Downloads/Mr.LDA-master/src/main/java/cc/mrlda/polylda/TermReducer.java:[24,11] error: generics are not supported in -source 1.3
    
    [ERROR] 
    [ERROR] (use -source 5 or higher to enable generics)
    [ERROR] /home/panwar/Downloads/Mr.LDA-master/src/main/java/cc/mrlda/TermReducer.java:[33,11] error: generics are not supported in -source 1.3 
    

    I'm using latest version of java.

    Solved: The problem was with maven. I was using an older version(maven3.0.2) other things were correct.

  • khmarbaise
    khmarbaise about 9 years
    Version 3.2 of maven-compiler-plugin is up-to-date.
  • JBA
    JBA about 9 years
    Well correct - were still using 3.1. :) - corrected to be at latest stable :)
  • Jens
    Jens over 7 years
    Why you think it is java 1.6? -source 1.3?