Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven Compile Error

When I build and run my program in Netbeans, it works without a problem. But with same pom.xml file when I try "mvn compile" I get this error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project hadoop-test: Compilation failure
[ERROR] /home/metin/NetBeansProjects/hadoop-test/src/main/java/com/citusdata/hadoop/HadoopTest.java:[53,8] error: generics are not supported in -source 1.3

My java version is not 1.3, here the result of "mvn -version"

Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.7.0_03, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.2.0-27-generic", arch: "amd64", family: "unix"

and this is the line 53:

Token<BlockTokenIdentifier> token = locatedBlock.getBlockToken();
like image 672
metdos Avatar asked Nov 08 '12 16:11

metdos


People also ask

What is Maven test compile?

mvn compile: Compiles source code of the project. mvn test-compile: Compiles the test source code. mvn test: Runs tests for the project. mvn package: Creates JAR or WAR file for the project to convert it into a distributable format.

What is Maven compile?

The Compiler Plugin is used to compile the sources of your project. Since 3.0, the default compiler is javax. tools. JavaCompiler (if you are using java 1.6) and is used to compile Java sources.


2 Answers

The problem is that maven-compiler-plugin in Maven2 by default uses -source 1.3 and target 1.3

You can fix it by adding this to your pom:

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

It's practical to put this into pluginManagement section in your topmost parent pom so that your derived poms do not need to care about this.

like image 120
Petr Kozelka Avatar answered Sep 18 '22 10:09

Petr Kozelka


You have to add some informations in your pom.xml. Something like that:

   <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
             <source>1.6</source>
             <target>1.6</target>
        </configuration>
  </plugin>
like image 40
Agemen Avatar answered Sep 18 '22 10:09

Agemen