简体   繁体   English

Netbeans用Java如何找到错误的来源?

[英]Netbeans with Java how to find the source of an error?

I use Netbeans for my Java IDE. 我将Netbeans用于Java IDE。 I am building off a 3rd party API. 我正在构建第三方API。 I have built quite a bit on top of it. 我已经在此之上建立了很多东西。 I try to leave good debugging messages around my code, but I am getting a very basic error message, then my program is closing. 我尝试在代码周围保留良好的调试消息,但收到一条非常基本的错误消息,然后程序关闭。 I get this Error - java.io.EOFException and then shortly after the program closes. 我收到此Error - java.io.EOFException ,然后在程序关闭后不久。 I think it is just a system output printed line showing the error coming from the API. 我认为这只是显示来自API的错误的系统输出打印行。

Does anyone know of a technique in Netbeans of Java in general where I could identify where the error is coming from? 有没有人知道Java Netbeans中的一种技术,我可以从中识别错误的出处?

One can put a break point on the constructor for EOFException(). 可以在EOFException()的构造函数上添加一个断点。

To do so: 为此:

  1. From the menu select Window -> Debugging -> Breakpoints or (Alt+Shift+5) 从菜单中选择窗口->调试->断点或(Alt + Shift + 5)
  2. In the Breakpoints window, right click for pop-up and choose New Breakpoint ... 在“断点”窗口中,右键单击以弹出并选择“ New Breakpoint ...
  3. Set Breakpoint Type to Method 将断点类型设置为方法
  4. Set classname to java.io.EOFException, for convenience click the All Methods for given class checkbox. 将类名设置为java.io.EOFException,为方便起见,单击“给定类的所有方法”复选框。 (otherwise you would have to set different breakpoints for the different constructors) (否则,您必须为不同的构造函数设置不同的断点)
  5. Choose Run -> Debug Project (Ctrl+F5) to debug your program. 选择运行->调试项目(Ctrl + F5)调试程序。 It should stop when the EOFException is created. 创建EOFException时应停止。
  6. Go to Window -> Debugging -> Call Stack to see where it was called from. 转到窗口->调试->调用堆栈以查看从何处调用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM