Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven : error: generics are not supported in -source 1.3 , I am using 1.6

Tags:

maven

I have imported an existing Maven project into Eclipse IDE . I have modified some code in it , it compiled successfully , I am using Java 1.6 as compiler and when i am trying to run maven clean install -X

Its giving the following error

could not parse error message: (use -source 5 or higher to enable generics) D:\bayer\util\src\main\java\com\tata\bayer\util\BrokerageCalendar.java:179: error: generics are not supported in -source 1.3

   private static Hashtable<String, Boolean> nyseHolidays = new Hashtable<String, Boolean>();                            ^  could not parse error message:   (use -source 5 or higher to enable generics) D:\bayer\util\src\main\java\com\tata\bayer\util\APIHttpXmlClient.java:27: error: generics are not supported in -source 1.3                         Class<? extends APIResponse> responseClass) {                          ^ 

Please suggest any ideas as how to resolve this ??

like image 255
Sonam Farzana Avatar asked Sep 29 '11 13:09

Sonam Farzana


2 Answers

Did you declare that you want to use java 1.6 in your project pom.xml?:

<build>         <pluginManagement>             <plugins>                 <plugin>                     <artifactId>maven-compiler-plugin</artifactId>                     <version>2.3.2</version>                     <configuration>                         <source>1.6</source>                         <target>1.6</target>                         <compilerArgument></compilerArgument>                     </configuration>                 </plugin>             </plugins>         </pluginManagement>     </build> 
like image 99
Shivan Dragon Avatar answered Oct 04 '22 04:10

Shivan Dragon


Configuring the Maven Compiler Plugin will fix the problem. It turns out the problem was caused by the Maven3 package in the Ubuntu repository. An alternate fix is to download Maven 3 from the Apache website which uses a more up to date Compiler plugin.

I wanted to know why this was happening when the documentation states the default Java source is 1.5. To see what mvn is using for your compiler plugin use:

mvn help:effective-pom 

My Maven Compiler Plugin was 2.0.2 even though I was using Maven 3.0.4 from the Ubuntu packages. When I run the same command using Maven 3.0.4 from Apache I have a plugin version 2.3.2, which defaults to Java 1.5 as expected.

like image 42
the_maplebar Avatar answered Oct 04 '22 04:10

the_maplebar