title: Building JARs with different JDK versions through Maven
body: <p>We are currently busy upgrading to Java 1.7.  Unfortunately, as these things go, a number of applications cannot be compiled under 1.7 and breaks (even with the override flag passed to 1.7). The plan is to re-factor these asap.</p>
  
  <p>I would like to configure Maven in such a way that different JDKs can be used based on some property in the POM. I followed <a href="http://maven.apache.org/plugins/maven-compiler-plugin/examples/compile-using-different-jdk.html" rel="nofollow">http://maven.apache.org/plugins/maven-compiler-plugin/examples/compile-using-different-jdk.html</a> to the letter, but no matter what I do, maven ignores the java specified in the POM.</p>
  
  <p>The POM has the following entry:</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;2.5.1&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;fork&gt;true&lt;/fork&gt;
                  &lt;source&gt;1.6&lt;/source&gt;
                  &lt;target&gt;1.6&lt;/target&gt;
                  &lt;compiler-version&gt;1.6&lt;/compiler-version&gt;
                  &lt;executable&gt;/usr/lib/jvm/java-6-openjdk/bin/javac&lt;/executable&gt; 
                  &lt;debug&gt;true&lt;/debug&gt;
                  &lt;verbose&gt;true&lt;/verbose&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
  ...
  </code></pre>
  
  <p>Furthermore, I get no output from the 'verbose' flag -- which I find odd.  Maybe the above is completely ignored?</p>
  
  <p>EDIT: I know it is not working, since inspecting the META-INF/MANIFEST.MF file shows the incorrect java version. The version used corresponds with the javac in the current path.</p>
  
  <pre><code>Manifest-Version: 1.0
  Archiver-Version: Plexus Archiver
  Created-By: Apache Maven
  Built-By: jaco
  Build-Jdk: 1.7.0_147-icedtea
  Implementation-Title: xxx
  Implementation-Vendor: xxx
  Implementation-Version: 1.3.7
  Specification-Title: xxx
  Specification-Vendor: xxx
  Specification-Version: 1.3.7
  </code></pre>
  
  <p>EDIT: Something else that is rather interesting.  If I purposefully break the file reference in , I get: </p>
  
  <pre><code>[INFO] Compilation failure
  Failure executing javac,  but could not parse the error:
  /bin/sh: /usr/lib/jvm/java-6-openjdk: Permission denied
  </code></pre>
  
  <p>EDIT: I suspect the problem lies with the component building the manifest file.  If I break java 7 on my machine (i.e. rename javac to javac.pleasegoaway), it compiles!! However, the manifest files still reports version 1.7.  This is now past annoying and getting hilarious.</p>
  
  <p>Some help will be greatly appreciated, thanks.</p>