title: `class file has wrong version` after Jenkins upgrade
body: <p>A couple of days ago, I upgraded Jenkins to version <code>1.643</code>. Before, we were using Jenkins <code>1.593</code>. Starting with Jenkins <code>1.612</code>, Jenkins requires Java 7, see <a href="https://jenkins-ci.org/changelog/" rel="nofollow noreferrer">changelog</a>, <a href="https://jenkins-ci.org/blog/2015/04/06/good-bye-java6/" rel="nofollow noreferrer">announcement</a> and <a href="https://issues.jenkins-ci.org/browse/JENKINS-28120" rel="nofollow noreferrer">issue</a>. Our Jenkins server has Java 8.</p>
  
  <p>I have a Maven project consisting of submodules.
  In the job configuration in Jenkins, I have configured the build to use JDK 1.6.</p>
  
  <p>When looking at the build environment, it's indeed 1.6:</p>
  
  <pre><code>JAVA_HOME=/var/lib/jenkins/tools/hudson.model.JDK/1.6
  </code></pre>
  
  <p>One of the submodules fails to build on Jenkins, with this error:</p>
  
  <pre><code>[ERROR] /var/lib/jenkins/&lt;REDACTED&gt;.java:[15,-1] cannot access java.lang.Object
  bad class file: java/lang/Object.class(java/lang:Object.class)
  class file has wrong version 52.0, should be 50.0
  </code></pre>
  
  <p>According to what I can Google, class file version 52.0 is JDK 1.8 while the compiler is expecting version 50.0, which is JDK 1.6. I assuming that class file 52.0 refers to <code>rt.jar</code> (Java Runtime) which contains <code>java.lang.Object</code> (see also <code>pom.xml</code> snippet below).</p>
  
  <p>I have found <a href="https://stackoverflow.com/questions/28180915/class-file-has-wrong-version-52-0-should-be-50-0">this SO question</a> (and others that are duplicate of it), but they are all in the context of someone building from their IDE (IntelliJ) or from command prompt, and after reading them, I don't see how I could apply the suggested solutions. They involve setting <code>$JAVA_HOME</code>, which is already done by Jenkins.</p>
  
  <p>My question is different because the issue is in the context of Jenkins (and Maven), and only occurred after the Jenkins upgrade. When I execute <code>mvn clean install</code> on my own desktop (with JDK 1.8), the error does not occur. If I execute the <code>file</code> command on the offending class file, but on the desktop where compilation succeeded, I get <code>compiled Java class data, version 50.0 (Java 1.6)</code>. For me, this confirms that my <code>pom.xml</code> is (probably) still correct and it's (probably) a Jenkins configuration issue.</p>
  
  <p>That specific submodule has this in the <code>pom.xml</code>, which may or may not be relevant:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
              &lt;configuration&gt;
                  &lt;source&gt;1.6&lt;/source&gt;
                  &lt;target&gt;1.6&lt;/target&gt;
                  &lt;compilerArguments&gt;
                      &lt;verbose /&gt;
                      &lt;bootclasspath&gt;${java.home}/lib/rt.jar&lt;/bootclasspath&gt;
                  &lt;/compilerArguments&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p>So, as you can see, it takes <code>rt.jar</code> from the current <code>$JAVA_HOME</code> so it can cross compile with a target of 1.6.</p>
  
  <p>I'm a bit lost about the origin of this  Java 8. Before the Jenkins upgrade, we were already using Java 8 on the server and cross compiling with a target of Java 6. What am I missing here?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Do I even <em>need</em> this? If I comment out</p>
  
  <pre class="lang-xml prettyprint-override"><code>                &lt;compilerArguments&gt;
                      &lt;verbose /&gt;
                      &lt;bootclasspath&gt;${java.home}/lib/rt.jar&lt;/bootclasspath&gt;
                  &lt;/compilerArguments&gt;
  </code></pre>
  
  <p>in <code>pom.xml</code>, I can still cross compile on my desktop and the class files are still version 50.0.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>When I take that part out, the build does not fail any more.
  Which means I solved it myself.</p>
  
  <p>I want to change the question to: <em>why</em> did it fail in the first place? And why didn't it fail before on Jenkins 1.593?</p>