title: Sbt: compile using Java 6 and run using Java 7
body: <p>I have a Scala 2.10.3 project that uses Swing. I have the following catch-22 situation:</p>
  
  <ul>
  <li>I must compile against Java 6 because of a bug with Scala Swing not working with Java 7</li>
  <li>I must run the project with Java 7 because OpenJDK 6 on Linux is broken (crashes with various Swing components)</li>
  </ul>
  
  <p>I can compile with </p>
  
  <pre><code>$ sbt -java-home /usr/lib/jvm/java-6-openjdk-amd64/ test:products
  </code></pre>
  
  <p>But when I try to run:</p>
  
  <pre><code>$ sbt run
  </code></pre>
  
  <p><code>sbt</code> figures that the JVM version changes, and tries to recompile everything, thus throwing a compile error due to the first problem.</p>
  
  <p>How can I convince <code>sbt</code> to run my project that was already compiled, although using a different JVM? Using <code>assembly</code> is not an option, because that takes several minutes, and I need to do this a lot.</p>
  
  <hr>
  
  <p>I also tried to switch using <code>export JAVA_HOME</code>, but this has the same effect, sbt will try to recompile upon <code>run</code>.</p>