问题
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)
Below is my code:
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();
}*/
}
}
回答1:
If you set a breakpoint and perform Run → Run instead of Run → Debug (or via the according toolbar buttons instead of ) the breakpoint is ignored.
See Help - Eclipse Platform, Launching a Java program in debug mode.
BTW, all uppercase variable names (WB, SH) should be used for final variables, i.e. constants only by convention.
And throwing a Throwable usually doesn't make much sense, since Error is a direct subclass of Throwable and its description reads:
An
Erroris a subclass ofThrowablethat indicates serious problems that a reasonable application should not try to catch.
来源:https://stackoverflow.com/questions/47483566/eclipse-debug-execute-java-program-without-stopping-at-breakpoint