title: How to compile with Java 11 target Java 1.8 in IntelliJ
body: <p>I am trying to compile with JDK 11 but target Java 1.8 in IntelliJ. I have configured:</p>
  
  <ul>
  <li>Project Settings:
  
  <ul>
  <li>Project SDK: 11</li>
  <li>Project language level: 8</li>
  </ul></li>
  <li>Java Compiler Settings:
  
  <ul>
  <li>Use '--release' option for cross-compilation (Java 9 and later)</li>
  <li>Project bytecode version: 8</li>
  </ul></li>
  <li>Module Settings:
  
  <ul>
  <li>Project SDK (11)</li>
  <li>Language level: Project default (8 - Lambdas, type annotations etc.)</li>
  </ul></li>
  </ul>
  
  <p>I get a bunch of compilation errors saying that internal packages do not exist. <code>--add-exports</code> is not valid with <code>--target 1.8</code> so that doesn't help.</p>
  
  <p>The only thing that does work is to set the Project SDK back to Java 1.8 (which causes other problems when trying to run with Java 11 but that is another issue).</p>
  
  <p>Is it possible to compile with JDK 11 and target Java 1.8 in IntelliJ?</p>
  
  <p>There are other related questions which seem to work but not from IntelliJ:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/54447541/how-to-produce-code-in-java-11-but-target-java-8-and-above">How to produce code in Java 11, but target Java 8 and above?</a></li>
  <li><a href="https://stackoverflow.com/questions/54147275/move-to-openjdk-11-but-compile-in-java-8">Move to OpenJDK-11 but compile in Java 8</a></li>
  </ul>