Tokci
Tokci

Reputation: 1280

Source not found error in Eclipse while debugging

I get below error and while debugging. When I put a breakpoint and debugging throws a 'source not found' error.

I already clicked on "Edit Source Lookup Path" in Eclipse and add my project. but its not working. Please suggest

Exception in thread "main" java.lang.NullPointerException
error line String value = cell.getStringCellValue();


     package ExcelPractice;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFEvaluationWorkbook;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class ExcelTest {    
    public static void main(String[] args) throws IOException {     
     String value = getExcelData("sheet1",2,2);
     System.out.println(" Cell Value " + value);     
    }   
    public static String getExcelData( String sheetName , int rowNum ,int cellNum) throws IOException{      
         FileInputStream fInput = new FileInputStream("C:\\Users\\xxxx\\Excel Data.xlsx");
         XSSFWorkbook wb = new XSSFWorkbook(fInput);
         XSSFSheet sheet = wb.getSheet(sheetName);
         XSSFRow row = sheet.getRow(rowNum);
         XSSFCell cell = row.getCell(cellNum);//breakpoint is here
         String value = cell.getStringCellValue();      
        return value;
    }
}

error screenshot enter image description here

enter image description here

enter image description here enter image description here

Upvotes: 1

Views: 1332

Answers (1)

nitind
nitind

Reputation: 20003

For classes in the standard Java Runtime, the easiest, simplest answer is always going to be to install a JDK, and to compile and run your Java Applications using it. Your Installed JREs preference page should ideally only list JDKs.

Upvotes: 1

Related Questions