Javac show error without warnings

I am using Sun javac 1.6.0_26. I call it like this:

javac -Xlint -encoding UTF-8 

and, as a rule, if there are errors, only them are displayed. However this code

 class Test{ public static void main(String args[]) { java.util.Date d = new java.util.Date(); system.out.println(d.getDate()); } 

issues warnings and errors:

 java:5: warning: [deprecation] getDate() in java.util.Date has been deprecated system.out.println(d.getDate()); ^ java:5: package system does not exist system.out.println(d.getDate()); 

So my question is: how do I make javac show only errors (no warnings) when there are any warnings, when there are no errors (never both)?

+4
source share
2 answers

-nowarn has a standard option that disables warning messages. You can get more details from javac-options

+7
source

It's a good idea to ignore compiler warnings. Most of the time they are really important. Only if you are sure that you want to ignore the warning, you can add an annotation:

 @SuppressWarnings("deprecation") System.out.println(d.getDate()); 

This is similar to what you think: let me fix the errors first and subsequently the warnings. But I do not think this is a good way to work. To resolve the warnings, you may have changed the code, and all your other troubleshooting steps were unnecessary because you needed a different code. It is always good to look at a problem all over the world.

+2
source

All Articles