I must be the anti-Maven since every time I try to use it I spend a lot of time struggling and then just give up. My latest is I can not compile Java 7 source code despite having a 1.7 JDK.
Here is the output of mvn compile
. The interesting thing is that when I was using Maven 3.0.4, the error message said -source 1.5
instead of -source 1.6
with Maven 3.2.1
[ERROR] .../src/main/java/pox/common/ServiceResponse.java:[300,43] diamond operator is not supported in -source 1.6
[ERROR] (use -source 7 or higher to enable diamond operator)
[ERROR] .../src/main/java/pox/common/ServiceRequest.java:[185,43] diamond operator is not supported in -source 1.6
[ERROR] (use -source 7 or higher to enable diamond operator)
As you can see I am using a recent version of Maven and Maven is using Java 1.7.
$ mvn -v
Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T12:37:52-05:00)
Maven home: /usr/local/maven
Java version: 1.7.0_40, vendor: Oracle Corporation
Java home: /usr/local/jdk1.7.0_40-x64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.18-371.4.1.el5", arch: "amd64", family: "unix"
I think the mvn
script is adding the /jre
since my environment variable does not specify it.
$ echo -e "$JAVA_HOME\n$M2_HOME"
/usr/local/java7-x64
/usr/local/maven
$ which javac
/usr/local/java7-x64/bin/javac
I was writing some POJOs that I wanted to Springify so I decided to use Maven and found this getting started with Maven on the Spring site.
http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#getting-started
I copied the pom.xml
and source from the site into my STS/Eclipse project that only contained Java source and tried to compile. STS has no problem compiling any of the source code in src/main/java
. I can remove the code that is dependent on Java 1.7 and get Maven to compile.
Every thing I have found so far implies I do not have my JAVA_HOME
set correctly but I am pointing to a 1.7 JDK.