I'm trying to create a file in Java. I have downloaded the lastest Apache POI version and kinda having troubles with all the "build path" thing. I'm not sure if I was doing everything right and not sure what jar files i should use. I try to run the code and thats the error I get:
Error: Unable to initialize main class TestCaused by: java.lang.NoClassDefFoundError: org/apache/poi/ss/usermodel/Workbook
My code:
import java.io.IOException;
import org.apache.poi.ss.usermodel.Cell;
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.XSSFWorkbook;
public class Test {
public static void main(String[] args) throws IOException {
Workbook workbook = new XSSFWorkbook("Test.xlsx");
Sheet sheet = workbook.createSheet("SheetTest");
Row headerRow = sheet.createRow(0);
for (int i = 0; i < 5; i++) {
Cell cell = headerRow.createCell(i);
cell.setCellValue(i);
}
workbook.close();
}
}
Maybe I have a problem with the classpath? How can I change it? If that's not the problem, Does anyone have an idea?