Eclipse调试无需中断即可执行Java程序 [英] Eclipse debug execute Java program without stopping at breakpoint

查看:79
本文介绍了Eclipse调试无需中断即可执行Java程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Java的新手,正在尝试调试Java代码,并希望在断点处停止执行。但是我在调​​试视图中得到以下消息:

I new to Java and I'm trying to debug a Java code and expecting to stop execution at breakpoint. But I get below message in my debug view:

<terminated>pullData [Java Application] 
    <terminated>Core_java.Excelread at localhost:57966  
    <terminated, exit value: 0>C:\Program Files\Java\jdk1.8.0_144\jre\bin\javaw.exe (25-Nov-2017, 12:04:21 PM)  

以下是我的代码:

 import java.io.*;
 import jxl.*;

 public class Excelread {

     public static void main(String[] args) throws Throwable {
         String Filename = "C:\\library\\TestData.xls";
         String Sheetname = "Source";
         String[][] arrayExcelData = null;
         FileInputStream fis = new FileInputStream(Filename);
         Workbook WB = Workbook.getWorkbook(fis);
         Sheet SH = WB.getSheet(Sheetname);
●        SH.getColumns();
         SH.getRows();

             /* System.out.println(TotalCol +" "+ TotalRow);
             arrayExcelData = new String [TotalRow][TotalCol];
             for (int i=0; i<TotalRow; i++) {
                 for(int j=0;j<TotalCol;j++) {
                     arrayExcelData[i][j] = SH.getCell(j,i).getContents();
                     System.out.print(arrayExcelData[i][j]+ "\t");
                 }
                 System.out.println();
             }*/
     }
 }


推荐答案

如果设置断点并执行 Run Run 而不是 Run Debug (或通过相应的工具栏按钮而不是)断点将被忽略。

If you set a breakpoint and perform RunRun instead of RunDebug (or via the according toolbar buttons instead of ) the breakpoint is ignored.

请参见帮助-Eclipse平台,以调试模式启动Java程序

BTW,所有大写变量名( WB SH )应用于 final 变量,即仅常量按惯例

BTW, all uppercase variable names (WB, SH) should be used for final variables, i.e. constants only by convention.

并抛出 Throwable 通常没有多大意义,因为 错误 Throwable 及其说明如下:

And throwing a Throwable usually doesn't make much sense, since Error is a direct subclass of Throwable and its description reads:


错误 Throwable 的子类,它指示严重的问题,即合理的应用程序不应尝试赶上。

An Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch.

这篇关于Eclipse调试无需中断即可执行Java程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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