Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 289
Sergii Getman Avatar asked Nov 06 '16 10:11

Sergii Getman


3 Answers

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

like image 118
Roberto Avatar answered Sep 20 '22 02:09

Roberto


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.

like image 42
Nicolai Parlog Avatar answered Sep 21 '22 02:09

Nicolai Parlog


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

like image 20
Dunx Avatar answered Sep 20 '22 02:09

Dunx