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

4

24

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.

Equiponderate answered 1/8, 2012 at 13:44 Comment(1)
It's javac hardcoded limit, you can try switching to Eclipse compiler in Settings | Compiler.Prance
P
3

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.

Prance answered 1/8, 2012 at 18:57 Comment(2)
You seem to be correct that it's due to the compiler, but Nicolas's solution of passing the -Xmaxerrors parameter works (no need to change compilers, at least in my case)Adze
I added the note to the top of the answer with the link to Nicolas Guillaume's because an incorrect answer, like this, stated with authority, might lead folks to do something that could cause lots of difficult-to-solve issues, especially in a team environment. I think there should be caveats given—even if this answer were correct—as it easily might (and, in fact, did) become a top result on searches related to the problem, causing unnecessary headaches when followed. I feel like we owe possibly inexperienced folks a bit of extra care when giving drastic answers like this, so… I gave it. ❤Parasympathetic
G
38

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.

Gerick answered 23/7, 2013 at 0:36 Comment(2)
If the Additional command line parameters text box doesn't seem to take effect. You may need to check the field below that in the Override compiler parameters per-module section to ensure your module isn't overriding with something else.Anthurium
This did not work on intellij 2022.1 with JDK 1.6 javac and I did not have any module overrides in effect.Markson
L
22

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"
        }
    }
}
Lorenalorene answered 9/8, 2015 at 14:26 Comment(1)
Did you put a space after X?Lorenalorene
M
5

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.

Markson answered 1/5, 2022 at 23:6 Comment(0)
P
3

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.

Prance answered 1/8, 2012 at 18:57 Comment(2)
You seem to be correct that it's due to the compiler, but Nicolas's solution of passing the -Xmaxerrors parameter works (no need to change compilers, at least in my case)Adze
I added the note to the top of the answer with the link to Nicolas Guillaume's because an incorrect answer, like this, stated with authority, might lead folks to do something that could cause lots of difficult-to-solve issues, especially in a team environment. I think there should be caveats given—even if this answer were correct—as it easily might (and, in fact, did) become a top result on searches related to the problem, causing unnecessary headaches when followed. I feel like we owe possibly inexperienced folks a bit of extra care when giving drastic answers like this, so… I gave it. ❤Parasympathetic

© 2022 - 2024 — McMap. All rights reserved.