Java compilation errors limited to 100
I have a Java file,which when I compiled, I will be able to see only first 100 errors on console after that java compiler(javac) exits. How will I be able to see all the compilation e开发者_如何学JAVArrors on console? Thanks in advance- opensid
Generally the compiler will give up after 100 errors. Most of the errors after this point will likely be caused by one of the first errors. If you must have more errors check out the javac options -Xmaxerrs
and -Xmaxwarns
If you're using gradle:
allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xmaxerrs" << "1000"
}
}
}
Have you tried the -Xmaxerrors
command line option? go here and search for "maxerrors"
In case you are using ant, the following will work :
<compilerarg line="-Xmaxerrs 10000" />
Note that you are using the "line" argument rather than "value" argument as in the answer above https://stackoverflow.com/a/42396745/2200690
If you're using Eclipse, Preferences > Java > Compiler > Building > General
will let you specify more problems per unit.
And if your using ant, make sure to use
<compilerarg value="-Xmaxerrs"/>
<compilerarg value="5"/>
and not
<compilerarg value="-Xmaxerrs 5"/>
I always forget.
The Java compiler gives up after a certain number of errors when compiling a file because Java is one of those languages that's hard to re-synch source to expected state after an error. This means that one single misplaced semi-colon can generate dozens of errors (or more—way more in some extreme edge cases) that have little to nothing to do with the actual error. There's no point in printing out "all the errors" in your source code because the majority of them are likely phantom errors.
Fix the first few clear, understandable errors you can find in your compiler output and try again. (Don't forget to look for variants of those errors in the rest of your source!) Getting more error messages per compile run will probably not help and will instead, in fact, just serve to bewilder and dishearten.
If you are using Windows operating system then try to compile your sources using Command Prompt. Then that command prompt won't exit on errors.
精彩评论