如何使用Netbeans在项目中显示所有Java编译器警告? [英] How to display all Java compiler warnings in a project using Netbeans?

查看:87
本文介绍了如何使用Netbeans在项目中显示所有Java编译器警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

来自Visual Studio和Eclipse,如何找出所有编译器警告,例如整个项目未使用的变量.看起来很琐碎,但却找不到.我可以在操作项"窗口中找到所有错误,但不是所有警告.

Coming from Visual Studio and Eclipse, How to find out all the compiler warnings such as unused variables for whole project. It seems like a trivial thing but can't find it. I can find out all errors in "Action Items" window but not all warnings.

推荐答案

似乎不可能.对此有一个开放的错误报告: https://netbeans.org/bugzilla/show_bug. cgi?id = 135014 .

It doesn't seem to be possible. There is an open bug report for that: https://netbeans.org/bugzilla/show_bug.cgi?id=135014.

它是旧的,最近才分配的(请参阅错误历史记录).

It's old and just recently assigned (see bug history).

您也可以尝试使用Source→检查.它与Java编译器警告不完全相同,但有所帮助.

As an alternative you can try Source → Inspect. It's not exactly the same thing as the Java compiler warnings, but helps a bit.

例如,在下面的代码中,它捕获了未使用的导入和空变量的使用,但没有报告未使用的变量(不过,已在NetBeans编辑器中正确注释了该变量).

For example, in the code below it caught unused imports and the usage of a null variable, but didn't report the unused variable (it was correctly annotated in the NetBeans editor, though).

import java.io.InputStreamReader; // Reported unused import

public class TestJava {
    public static void main(String[] args) {

        String input = null;
        String unused; // DID NOT report unused variable

        System.out.println("Input "+ input); // Reported usage of null
    }
}

只需确保安装FindBugs插件即可充分利用它. 检查对话框将警告该插件丢失,并为您安装.

Just make sure you install the FindBugs plugin to get the most out of it. The Inspect dialog box will warn that the plugin is missing and install for you.

这篇关于如何使用Netbeans在项目中显示所有Java编译器警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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