tags:

views:

135

answers:

7

Hi All, 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 errors on console? Thanks in advance- opensid

+7  A: 

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

krock
Thanks Krock, it worked
sid
+2  A: 

Have you tried the -Xmaxerrors command line option? go here and search for "maxerrors"

Peter Recore
Thanks Peter its -Xmaxerrs
sid
A: 

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.

Multiplexer
Thanks Purushotham but I am using Linux!!!
sid
Then you can compile that using the Terminal.If you still not able to see then use printStack method to print the error message in a file.
Multiplexer
Yes Purushotham, I am using Terminal, but I was having compilation errors, I was interested in knowing errors beyond 100, With "javac -Xmaxerrs 200" I am able to see 200 errors.
sid
Thats good man..
Multiplexer
A: 

If you're using Eclipse, Preferences > Java > Compiler > Building > General will let you specify more problems per unit.

trashgod
+1  A: 

Perhaps you could try fixing your errors? :P

Nathan Tomkins
Thanks Nathan, I was interested in knowing how much errors may occur by simple mistakes.
sid
A: 
JUST MY correct OPINION
I was interested in knowing how much errors may occur by simple mistakes.
sid
You won't find it. That's the point. Most of the errors are phantom errors caused by parser limitations (and the nigh-unparseable nature of Java). All you'll find is that the compiler is really stupid and can't figure out real errors vs. "errors of misopportunity".
JUST MY correct OPINION
I don't know why you think Java is 'one of those languages that's hard to re-synch source to expected state after an error' and 'nigh-unparseable'. It's a pretty standard semicolon-terminator language, of the kind we've been building solid parsers for for decades, and parsers do have error recovery in them, since the 1970s if not earlier. Cascading compile errors are more usually due to undeclared identifiers and other *semantic* errors.
EJP
And yet many other languages, when faced with such semantic errors, don't spew dozens to hundreds of error messages. They seem to have the smarts to figure out what such an error causes in later code and know, thereby, how to ignore it.C, C++ and Java compilers can't seem to figure this out.
JUST MY correct OPINION
Eclipse, (and all the other ide's I'm sure) don't seem to have much problem recovering. they don't paint my entire screen red with squigglies when i have an error, just the appropriate sections.
Peter Recore
'And yet ...' ... this is still nothing to do with Java being 'nigh-unparseable'. I haven't noticed that Java is prone to cascading errors, syntactical or semantic, but then I don't compile source code that gives 100 compiler errors. FYI C and C++ are both much harder to parse than Java: both have typedefs, which require semantic feedback to disambiguate them, and C++ has > 50 shift/reduce conflicts, showing that syntax design wasn't exactly Stroustrup's greatest strength. Java doesn't have either of these problems. In short I don't see any basis for your claims.
EJP
A: 

Perhaps a bit more work than -Xmaxerrors, but you could capture the full stack trace as a string and then do what you wish with it...

See the example here... http://www.java2s.com/Code/Java/Language-Basics/ConvertanexceptiontoaStringwithfullstacktrace.htm

matsuzine
-1 because this won't work - if he's getting a compiler error it won't run, so you won't get exceptions and stack traces.
Nathan Tomkins
Opps, you're right. I was thinking stack trace, but he clearly asked about compiler errors.
matsuzine