Sometimes you just do some typo in code but compiler will output dozens of errors, (actually it just fails to compile efter the first typo). So it would be very convenient sometimes to limit the compiler output to first error detected. GCC/Clang will accept -Wfatal-errors
, can javac
do the same? I am using JDK7 for Windows.
Asked
Active
Viewed 2,700 times
5

exebook
- 32,014
- 33
- 141
- 226
-
Wow, thank you guys for three correct answers so fast. – exebook Mar 12 '13 at 11:35
4 Answers
6
See this answer: https://stackoverflow.com/a/3115546/500478
You can use -Xmaxerrs
and -Xmaxwarns
to set the maximal number of errors/warnings before javac
gives up.

Community
- 1
- 1

Bastien Jansen
- 8,756
- 2
- 35
- 53
3
Whenever javac generates errors, it will stop "soon after", with or without -Xmaxerrs.
-Xmaxerrs and -Xmaxwarns simply limit the number of messages generated.

Jonathan Gibbons
- 696
- 3
- 5
1
javac
has the -Xmaxerrors
option, described in the man page as
-Xmaxerrors number
Set the maximum number of errors to print.
but I don't know whether -Xmaxerrors 1
will actually cause it to give up after it hits the first error or if it carries on but then only actually prints one error at the end.

Ian Roberts
- 120,891
- 16
- 170
- 183