23

I have this all working in eclipse and am trying to do so in intellij now. I opened settings {command and comma} then went to Build, Execution and Deployment and clicked Compiler and in Shared Build Process VM Options I typed in "-parameters" but intellij errored out when I built the project with "Unrecognized option: -parameters"

My project is compiling fine in jdk8 and I am using jdk 8 lambdas and other jdk features. I don't get why I can't get my code compiled with parameters build in.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Dean Hiller
  • 19,235
  • 25
  • 129
  • 212

2 Answers2

48

The "Shared build process VM options" field, as its name implies, is used to specify the VM options for the shared build process. The shared build process is not javac, and -parameters is not a VM option. Therefore, the option is not recognized.

The correct place to enter the -parameters option is Settings > Build, Execution, Deployment > Compiler > Java Compiler > Additional command line parameters.

yole
  • 92,896
  • 20
  • 260
  • 197
  • 17
    remember to rebuild your project, or it may not work. – min Jun 04 '17 at 07:15
  • 1
    @yole can you please update the answer? I am using 2018.3 version of IntelliJ and I am unable to find the fore-mentioned settings path. – Saiteja Parsi Mar 20 '19 at 06:59
  • @SaitejaParsi The setting is at exactly the same path in 2018.3. – yole Mar 22 '19 at 16:15
  • 1
    @yole I am running 2018.3.5 and also do not see the setting where you described. – Greg Brown Mar 25 '19 at 22:58
  • 2
    OK, I found it. It's under Preferences > Build, Execution, Deployment > etc. I had been looking for it under the Build menu. I have the compiler flag set in my Gradle script, but IDEA is ignoring it for some reason. – Greg Brown Mar 25 '19 at 23:10
  • 4
    If you don't have "Delegate IDE build/run actions to Gradle" enabled in Settings | Build, Execution, Deployment | Build Tools | Gradle | Runner, IntelliJ IDEA will build the project using its own compiler, which will not use the build options specified in build.gradle. If you enable this option, the build will run through Gradle and use the options in your build.gradle. – yole Mar 26 '19 at 11:40
1

If you cannot find an option under Settings > Build, Execution, Deployment > Compiler > Java Compiler (like me in 2021.1.1) you can specify it in your build.gradle file (like here):

tasks.withType(JavaCompile) {
    options.compilerArgs << '-parameters'
}
artaxerx
  • 244
  • 1
  • 3
  • 11