我有一些嚴重的困難讓我的項目離開地面。我有以下代碼:使用Apache POI的Java程序讓我感到奇怪例外
FileInputStream file = new FileInputStream(new File("src/retestchecker/test_sheet.xlsx"));
//Get the workbook instance for XLS file
XSSFWorkbook workbook = new XSSFWorkbook(file);
//Get first sheet from the workbook
XSSFSheet sheet = workbook.getSheetAt(0);
Row row = sheet.getRow(0);
Cell x = row.getCell(3);
System.out.println(x);
我得到這個錯誤,我不知道這意味着什麼:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlException
at retestchecker.RetestChecker.main(RetestChecker.java:23)
Caused by: java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlException
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
Java Result: 1
我使用NetBeans和這是5月11日發佈的Apache POI的最新版本,2015年
的錯誤指的便是這條線的第23行:
XSSFWorkbook workbook = new XSSFWorkbook(file);
什麼我做錯了嗎?
似乎你沒有在類路徑上的所有必需的庫。如果你還沒有,你可能想嘗試一下Maven。 – aioobe