The program works fine on another PC. I imported it on my home PC, where it doesn't work.
Line of error:
wwbCopy = Workbook.createWorkbook(new File("bstncopy.xls"), wbook);
Stacktrace:
java.lang.NullPointerException
at jxl.read.biff.ExternalSheetRecord.getNumRecords(ExternalSheetRecord.java:135)
at jxl.write.biff.ExternalSheetRecord.<init>(ExternalSheetRecord.java:107)
at jxl.write.biff.WritableWorkbookImpl.<init>(WritableWorkbookImpl.java:219)
at jxl.Workbook.createWorkbook(Workbook.java:325)
at jxl.Workbook.createWorkbook(Workbook.java:306)
at ReadDataBst.<init>(ReadDataBst.java:28)
at Graph.<init>(Graph.java:23)
at Dijkstra.<init>(Dijkstra.java:4)
at GUIWindowBuilder.<init>(GUIWindowBuilder.java:28)
at Main.main(Main.java:6)
Based on the stack trace, it looks like your code attempts to dereference a null pointer, hence the NullPointerException. As you suggested the line of error:
wwbCopy = Workbook.createWorkbook(new File("bstncopy.xls"), wbook);
did you check that Workbook.createWorkbook(new File("bstncopy.xls"))
returns a non-null object or wbook
is a non-null object before this point?
I believe the problem is associated with those two entities being null. So, before creating work book, check if both the items associated with the line of error are not null object.
You can do something like this.
File file = new File("bstncopy.xls");
if(file != null && wbook != null){
wwbCopy = Workbook.createWorkbook(file, wbook);
}