Attempt to write using POI 5.0.0 give java.lang.NoClassDefFoundError: org/apache/poi/hssf/usermodel/HSSFWorkbook

601 views Asked by At

So I downloaded Ant POI 5.0.0 and installed (to the best of my knowledge) it to my lib directory for use in my project.

when I try execute the following code:

XSSFWorkbook book = new XSSFWorkbook(new FileInputStream(xlFile));
XSSFSheet sheet = book.getSheetAt(0);

I get "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/poi/hssf/usermodel/HSSFWorkbook" but I know at least this directory and classes are there. What other classes am I missing?

I'm also using the following imports.

import org.apache.poi.hssf.usermodel.HSSFCell; 
import org.apache.poi.ss.usermodel.Cell; 
import org.apache.poi.ss.usermodel.CellStyle; 
import org.apache.poi.ss.usermodel.DataFormat; 
import org.apache.poi.ss.usermodel.Row; 
import org.apache.poi.ss.usermodel.Sheet; 
import org.apache.poi.ss.usermodel.Workbook; 
import org.apache.poi.xssf.usermodel.XSSFRow; 
import org.apache.poi.xssf.usermodel.XSSFSheet; 
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

Just for clarification, I have included my compiler command just in case I am missing something in my classpath as well.

javac -g -d ..\bin SomeApp.java -cp ..\src;..\lib\poi-ooxml-5.0.0.jar;..\lib\poi-5.0.0.jar

1

There are 1 answers

0
Vuzi On

Faced a similar issue, using Eclipse Enterprise Enterprise, version: 2019-06 (4.12.0). I had added apache-poi 5 jars in a user library enter image description here

The project compiled fine. But when I run the web application on my location machine, was getting the error

What I was missing in eclipse was to include the following

enter image description here

After this, everything was working fine