Inspectopedia 2025.3 Help

Multiple main methods

Reports classes or files that contain multiple overloaded main methods in Groovy 5.

When a class or file has several main methods with different signatures, it can be unclear which one serves as the application's entry point because the invocation of the main method occurs at runtime based on the presence of arguments. Consider the following example:

class A { void main(String[] args) { println "1" } void main() { println "2" } }

If no arguments are passed, then the main(), otherwise the main(String[]) will be invoked.

Locating this inspection

By ID

Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.

GroovyMultipleMainMethods
Via Settings dialog

Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.

Settings or Preferences | Editor | Inspections | Groovy | Control flow issues

Inspection ID: GroovyMultipleMainMethods

Suppressing Inspection

You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:

//noinspection GroovyMultipleMainMethods

More detailed instructions as well as other ways and options that you have can be found in the product documentation:

Inspection Details

By default bundled with:

IntelliJ IDEA 2025.3, Qodana for JVM 2025.3,

Last modified: 03 December 2025