I am trying to start a new JDK 9 project in IntelliJ, but when I attempt to run it I get the following error during the make process:
Error:java: invalid flag: -release
I know I haven't set it up correctly but can't seem to find anything relating to setting up a project with Jigsaw in IntelliJ.
Edit
Here is a screen shot of the issue. Haven't been able to find anything related to this anywhere.
I have no compiler errors in the IDE. It just fails on the build/run command. This is a clean install of IntelliJ, new project started with the JDK 9.
I was able to set the JDK level to experimental and it worked.
Hopefully this will help others who run into this issue.
The error message complains about the unrecognized option -release
. This is a compiler flag that was introduced in Java 9. Are you sure your project is using a JDK 9?
What is strange is a detail of the message. This is what I get for java
and javac
on different versions:
- Java 8 (u102) +
javac -release
~> javac: invalid flag: -release
- Java 8 (u102) +
java -release
~> Unrecognized option: -release
- Java 9 (ea131) +
javac -release
~> javac: -release requires an argument
- Java 9 (ea131) +
java -release
~> Unrecognized option: -release
I'm unclear how you got java
(not javac
) to complain with invalid flag
.
The -release flag is a valid argument for javac but not for java. And in fact if you are building a Java 9 project you don't need it either way. Are you specifying it somewhere? If there is place to specify release in IntelliJ, you can try to turn it off. Also you could post the command IntelliJ is running here, and try to run the command yourself.
I think this is the bug:
Error:java: invalid flag: -release when compiling using java 9 early access build 135 +
In other words:
- The fix should eventually appear in a stable IntellIJ build. (Hopefully in the next one!)
- You could probably download an early access build of IntelliJ to get the fix sooner.
- Or you could downgrade to an older early access build of Java 9 (before 135).