sorin
sorin

Reputation: 170648

How to increase the error limit of 100 errors on IntelliJ IDEA?

I have an IntelliJ IDEA project but the compilation stops when it does encounter more than 100 errors and I would like to increase the limit in order to figure it out how much I do have to "refactor" the ancient code.

Upvotes: 25

Views: 14585

Answers (4)

cb4
cb4

Reputation: 9383

2022 UPDATE

The question is old but still valid when wanting to use current IDE technology on legacy code. For a maven build in intellij, Nicolas Guillaume's answer will not work - those settings are rightly overridden by maven. However, this configuration will yield the same result:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.10.0</version>
    <configuration>
        <fork>true</fork>
        <compilerVersion>1.5</compilerVersion>
        <executable>C:\Java\jdk-1.5.0_22\bin\javac.exe</executable>
        <source>1.5</source>
        <target>1.5</target>
        <compilerArgs>
            <arg>-Xmaxerrs</arg>
            <arg>1000</arg>
            <arg>-Xmaxwarns</arg>
            <arg>2000</arg>
        </compilerArgs>
    </configuration>
</plugin>

Some sources (even on SO) state that the correct option for Java5 is -Xmaxerrors, which is incorrect as reported in this bug. And that option didn't exist in 1.4 and earlier versions.

Upvotes: 5

Nicolas Guillaume
Nicolas Guillaume

Reputation: 8434

The 100 error limit you are seeing is not a limit of IntelliJ IDEA, per se, but is a default for the javac compiler that is being used to compile an application. After IDEA is using. the default number of errors, after is the default for the standard Sun/Oracle javaccompiler, but can be modified by passing an argument to the compiler; as can the maximum number of warnings, which also defaults to 100.

The online documentation for javac (e.g., the Java SE version 7 page at 'javac - Java programming language compiler') gives these arguments (in the section "Options", under the sub-heading "Non-Standard Options") as follows:

-Xmaxerrs number
     Set the maximum number of errors to print.

-Xmaxwarns number
     Set the maximum number of warnings to print.

When using javac in IntelliJ IDEA, these (and other) compiler arguments can be added by navigating to the settings for the project (e.g. F̲ile > Set̲tings or Ctrl+Alt+S); then, under the Project Settings heading, expand the ▼ Compiler section, select Java Compiler and enter the desired setting(s) into the text box following Additional command line parameters:. (e.g. to increase the limits to 123 errors and 456 warnings, enter -Xmaxerrs 123 -Xmaxwarns 456 into the textbox.)

  from http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javac.html, retrieved 2014-07-31, Archived by WebCite® at http://www.webcitation.org/6RTlsAI8T

  this process was vetted on version 13, by shelleybutterfly, and version 12 by Nicolas Guillaume, but the process is likely very similar, if not the same, for other versions.

Upvotes: 39

Timmmm
Timmmm

Reputation: 96832

If you're using Gradle (probably because you're using Android), change the allprojects bit of your Project build.gradle (not the Module one) as follows:

allprojects {
    repositories {
        jcenter()
    }

    // Allow 400 errors.
    gradle.projectsEvaluated {
        tasks.withType(JavaCompile) {
            options.compilerArgs << "-Xmaxerrs" << "400"
        }
    }
}

Upvotes: 23

CrazyCoder
CrazyCoder

Reputation: 402375

Note: Although it is possible to change to the Eclipse compiler as suggested by this answer, it is not necessary to solve this particular issue. Instead, you can simply add an argument to your compiler settings that alters the maximum number of errors displayed by the javac compiler (as described in this alternate answer to the question by Nicolas Guillaume).

As there may be subtle issues that arise when switching to a different compiler or compiler version on an existing project, make sure you understand the consequences given your particular circumstances prior to making a switch such as the one described below.

This limit is not enforced by IntelliJ IDEA, it's compiler specific (in this case javac compiler has a limit of 100 errors).

To workaround this problem you can switch to another compiler in Settings | Compiler | Java Compiler. Eclipse compiler should be able to show more errors.

Upvotes: 3

Related Questions