1

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

Tokci
  • 1,220
  • 1
  • 23
  • 31
  • Possible duplicate of [Eclipse java debugging: source not found](http://stackoverflow.com/questions/6174550/eclipse-java-debugging-source-not-found) – Ario Oct 08 '16 at 09:45
  • I did read the answer. but I am not sure..how to implement it or what exactly needs to be done, I did 'edit source lookup path' and gave path of my project , but issue still persist .. I am not sure how to implement other solutions. – Tokci Oct 08 '16 at 13:51
  • You would need to actually track down the source and store it locally. It usually is not in the runtime JAR file. – nitind Oct 12 '16 at 19:05

1 Answers1

1

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.

nitind
  • 19,089
  • 4
  • 34
  • 43
  • Your screenshot contains only a JRE, not a JDK. – nitind Oct 08 '16 at 17:10
  • added JDK now I get to Reader.class( in place of source not found for inputStream , I want to skip this , if I step over [F6] then I get Source not found 'Class File Editor'... – Tokci Oct 08 '16 at 17:55
  • @nitnd ..can you please throw some light on my issue in comments above or I need to create a new question ? – Tokci Oct 10 '16 at 09:21
  • @Tokci I'd need to see a screenshot of that to understand it, and it's starting to sound like a different problem. I would go ahead and remove the JRE from the Installed JREs preference page, just so you don't use it for anything. – nitind Oct 10 '16 at 17:21
  • added screenshot, refer to last screenshot, if I uncheck NullpointerException in Breakpoints section then I get pass thru the issue and reach my code but again in next step I get stuck into XSSFCell.class 'source not found'..not sure how to resolve it., please help!! – Tokci Oct 11 '16 at 19:06
  • accepted the answer , it is most use full but I am still not able to find the root cause, will update the answer once I get it. – Tokci Oct 16 '16 at 17:10
  • This only remains an error if the source file for `XSSFCell` is *actually* in your project, laid out in the correct tree structure for its `package` declaration. It's unusual to ship source files with a production jar file ("release artifacts"), and for POI it is a separate download. Sometimes it's simply not available. Which case is this? – nitind Oct 17 '16 at 04:48