Error:java: invalid flag: -release

I was using Java 8 and Intellij 2018.1.1

I solved the issue in this way:

  • open IntelliJ Idea settings
  • navigate to Build, Execution, Deployment > Compiler > Java Compiler
  • Uncheck the option: Use '--release' option for cross-compilation (Java 9 and later)

Intellij Settings


Java 9 support is cutting edge and should be tried with the most current version. At the moment, this is the public preview of 2016.3, available here.


Had exactly the same Error:java: invalid flag: -release in Intellij 2017.1. Updating to 2017.2.5 resolves the issue.