I'm getting below message when I run mvn clean install
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
D:\data\work\extjs.parser\src\main\java\com\model\Component.java:[17,15] error:
generics are not supported in -source 1.3
could not parse error message: (use -source 5 or higher to enable generics)
D:\data\work\extjs.parser\src\main\java\com\model\Container.java:14: error: gene
rics are not supported in -source 1.3
private List<Component> items;
the project is a simple Maven project, but won't compile with generics error when I have already set JAVA_HOME to the JDK 1.7 installation path
However, when I add a plugin, then it works fine. Why is it required to explicitly set the Java home path?
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
<executable>${env.JAVA_HOME}/bin/javac</executable>
<fork>true</fork>
</configuration>
</plugin>
This is an old question, and after waiting for quite some time back then, I didn't get an answer. However, while browsing the Maven compiler plugin documentation, I came to know that plugin has default settings. So, earlier versions used to use JDK 1.3 as default for source/target, and now it uses 1.5. After reading docs and running mvn clean install -X
, I observed that
Hence there was an error as maven-compiler-plugin and its configuration (source/target) were not specified in the POM.