'Error:java: invalid flag: -release
I use Java :
Java(TM) SE Runtime Environment (build 9-ea+143) Java HotSpot(TM) 64-
Bit Server VM (build 9-ea+143, mixed mode)
and IntelliJ IDEA:
IntelliJ IDEA 2016.2.5 Build #IU-162.2228.15, built on October 14,
2016
Get error when compiling:
Error:java: invalid flag: -release
Executing javac -help :
--release <release>
Compile for a specific VM version. Supported targets: 6, 7, 8, 9
So javac should use two hyphens with release, but Intellij Idea use with one.
Can I override javac options that IDEA use or fix it in some way?
UPD: Even Build, Execution, Deployment > Compiler > Java Compiler Additional Command Line Parameter doesn't help in this case
Solution 1:[1]
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)
Solution 2:[2]
Had exactly the same Error:java: invalid flag: -release in Intellij 2017.1. Updating to 2017.2.5 resolves the issue.
Solution 3:[3]
Can be caused by mismatch of java version on build configuration and module settings.
Solution 4:[4]
As specified in this intellij thread you can workaround it by setting the project SDK language level to x - Experimental Features

Solution 5:[5]
I had the same problem with IntelliJ IDEA Version 2017.1.3
Updated IntelliJ to Version: 2017.3.4 and with the latest version it works fine.
Solution 6:[6]
Remove --warning-mode=all (File -> Setting -> Build, Execution, Deployment -> Java Compiler
Solution 7:[7]
You can check the JDK version, if its less than JDK8, upgrade and try again. It solved my issue.
Solution 8:[8]
Remove the release tag in configuration of maven-compiler-plugin
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
... #here
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
Solution 9:[9]
There are a lot of things to look at, you can review this blog post Troubleshooting Page Load Issues to get started. Also, go to check the ULS logs, maybe you will find some related clues there.
Solution 10:[10]
After I viewed ULS log I found out this error that seems related to my issue: An unexpected error occurred while manipulating the navigational structure of this Web.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow


