I am using this code:
URL excelResources = Excel_file_reader.class.getClass().getResource("/Test_Cases.xlsx");
to read an excel file in case I will have to create a jar. I keep getting a null pointer exception.
I ran the exact same project on my personal computer and the code actually runs and the program can read the excel values. But on my work computer the code does not run and results in a null pointer exception. On both computers I created a resources folder and added it to the project path. The excel file is placed in the same locations on both computers. I know the JDK and eclipse versions are different but I don't think that should make a difference. On my work computer I have admin rights too. I have cleaned the project and tried multiple times. When i use
System.out.println(excelResources.getPath());
File excel = new File(excelResources.toURI());
FileInputStream ExcelFile= new FileInputStream(excel);
On my personal computer the path gets printed, but on my work computer it returns as a null pointer.
Please suggest.