title: How can I configure Maven to use JDK6 by default, but JDK7 as needed
body: <p>I have both JDK 1.6 and 1.7 installed on my system (Linux, under the /opt directory).
  I've added the bin directory for JDK 1.6 in my path, so that's the version of Java used by default.</p>
  
  <p>I'm working on a project that requires JDK 1.7 and some that require 1.6. Previously I had set JDK 1.7 settings within Eclipse, but I wanted to convert this project to Maven so that everyone could use their preferred editor.</p>
  
  <p>Is it possible to specify the 1.7 location on a Maven installation/configuration (and not in the POM file) such that it uses 1.6 by default and 1.7 when specifying the project requires it in the POM? As far as I am aware, everyone working on a project should have the same contents in their POM files, so I am reluctant to set the location of the Java 7 directory here (as it'll be different on everyone's machines).</p>
  
  <pre><code>$ mvn --version
  Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 13:51:28+0000)
  Maven home: /opt/apache-maven-3.0.5
  Java version: 1.6.0_45, vendor: Sun Microsystems Inc.
  Java home: /opt/jdk1.6.0_45/jre
  Default locale: en_GB, platform encoding: UTF-8
  OS name: "linux", version: "3.8.0-27-generic", arch: "amd64", family: "unix"
  </code></pre>
  
  <p>Adding the following: </p>
  
  <pre><code>&lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
          &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
          &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
          &lt;version&gt;3.1&lt;/version&gt;
          &lt;configuration&gt;
              &lt;source&gt;1.7&lt;/source&gt;
              &lt;target&gt;1.7&lt;/target&gt;
          &lt;/configuration&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
          &lt;artifactId&gt;maven-resources-plugin&lt;/artifactId&gt;
          &lt;version&gt;2.6&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;outputDirectory&gt;${project.build.outputDirectory}/resources&lt;/outputDirectory&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p>results in:</p>
  
  <pre><code>[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project golemlite: Fatal error compiling: invalid target release: 1.7 -&gt; [Help 1]
  </code></pre>