javac显示错误而没有警告 [英] javac show error without warnings

查看:39
本文介绍了javac显示错误而没有警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Sun 的 javac 1.6.0_26.我这样调用它:

I'm using Sun's javac 1.6.0_26. I invoke it like this:

javac -Xlint -encoding UTF-8 

并且通常如果有错误,则只显示它们.但是这段代码

and usually 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());
    }

产生警告和错误:

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());

所以我的问题是:当有任何和所有警告而没有错误(从来没有)时,我如何让 javac 只显示错误(没有警告)?

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

推荐答案

javac -nowarn 中有一个标准选项可以禁用警告消息.您可以从 javac-options

There is a standard option in javac -nowarnwhich disable warning messages. You can get more informations from javac-options

这篇关于javac显示错误而没有警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆