I am trying to compile with JDK 11 but target Java 1.8 in IntelliJ. I have configured:
- Project Settings:
- Project SDK: 11
- Project language level: 8
- Java Compiler Settings:
- Use '--release' option for cross-compilation (Java 9 and later)
- Project bytecode version: 8
- Module Settings:
- Project SDK (11)
- Language level: Project default (8 - Lambdas, type annotations etc.)
I get a bunch of compilation errors saying that internal packages do not exist. --add-exports
is not valid with --target 1.8
so that doesn't help.
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).
Is it possible to compile with JDK 11 and target Java 1.8 in IntelliJ?
There are other related questions which seem to work but not from IntelliJ: