title: Maven Won't Compile Java 7 with 1.7 JDK
body: <p>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. </p>
  
  <p>Here is the output of <code>mvn compile</code>. The interesting thing is that when I was using Maven 3.0.4, the error message said <code>-source 1.5</code> instead of <code>-source 1.6</code> with Maven 3.2.1</p>
  
  <pre><code>[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)
  </code></pre>
  
  <p>As you can see I am using a recent version of Maven and Maven is using Java 1.7.</p>
  
  <pre><code>$ 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"
  </code></pre>
  
  <p>I think the <code>mvn</code> script is adding the <code>/jre</code> since my environment variable does not specify it.</p>
  
  <pre><code>$ echo -e "$JAVA_HOME\n$M2_HOME"
  /usr/local/java7-x64
  /usr/local/maven
  
  $ which javac
  /usr/local/java7-x64/bin/javac
  </code></pre>
  
  <p>I was writing some POJOs that I wanted to <i>Springify</i> so I decided to use Maven and found this getting started with Maven on the Spring site.</p>
  
  <p><a href="http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#getting-started" rel="nofollow">http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#getting-started</a></p>
  
  <p>I copied the <code>pom.xml</code> 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 <code>src/main/java</code>. I can remove the code that is dependent on Java 1.7 and get Maven to compile.</p>
  
  <p>Every thing I have found so far implies I do not have my <code>JAVA_HOME</code> set correctly but I am pointing to a 1.7 JDK.</p>