Question

I am using maven to compile some java classes. One of the classes has an annotation(@Override) so when i run mvn compile then I get error:

 annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
        @Override

 annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
        @Override

Although the java version in my system is jdk 1.6.29 still i can't understand this error. So i there a way by which i can check the jdk version maven is using and perhaps change it. Or, is there any other solution? Thanks.

Was it helpful?

Solution

You need to instruct the maven build to set the compiler flags for compilation of java source level 1.5. This is done inside your pom.xml file, adding configuration for the maven-compiler-plugin plugin.

For instance:

<plugins>
[...]
     <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>2.3.2</version>
          <executions>
              <execution>
                  <id>default-compile</id>
                  <configuration>
                       <source>1.5</source>
                       <target>1.5</target>
                  </configuration>
              </execution>
              </executions>
     </plugin>
[...]
</plugins>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top