I am new to Intellj. What the meaning of - override compiler parameters per module? what happen if i remove parameter ?The screen shot for more detail.
1 Answers
Oddly this section of the dialog "Override compiler parameters per module" is not currently documented in the Idea help guide.
What it does is add parameters to the javac
compiler when compiling a specified module.
An example usage is to allow the compiler to access a class which is in a package not exported by a module (java platform module, not IDE or Maven module) that you are relying on.
For example, let's say you have the issue detailed here:
Where you are using the JavaFX WebView, and want to listen to console messages generated by JavaScript running in the WebView. There is a class (com.sun.javafx.webkit.WebConsoleListener
) to allow listening to console message log events in the com.sun.javafx.webkit
package. But that package is private, internal API for the module and not exported by it.
So when you try to use the WebConsoleListener
class, Idea will just highlight it in red and give a message that it can't find the class when you try to compile.
To fix that you can press alt+enter on the red line and Idea will prompt you if you want to add an export statement to the module compilation options, if you say yes, it will record that option here, using, for example, the "Compilation options" for the module as:
--add-exports javafx.web/com.sun.javafx.webkit=com.example.webviewloadtest
Where, is this example, com.example.webviewloadtest
is your own custom module name used within your application (the name of the module in the module-info.java
file).
Once that is done, the classes in the specified package will be visible to your module during compilation and the IDE will no longer highlight the import and usage of the WebConsoleListener
class in red (because the intelligent editor in IDE now also knows about the class, so can perform error checking during editing and auto-completion of its methods, etc).
Note, that the options specified in the "Override compiler parameters per-module" options are only compiler options, they are not runtime options.
If you also want the class in this example visible at runtime you also need to manually add the same --add-exports
statement to the VM options of the runtime configuration that you use to run the application.
--add-exports javafx.web/com.sun.javafx.webkit=com.example.webviewloadtest
Note, Eclipse IDE also has a similar feature to "Override compiler parameters per module", see:

- 150,031
- 14
- 366
- 406