Why poi-4.1.2 for xls dos not find dependencies even though classpath is right?

I am building a simple project using Ant (not Maven as I need the project to be build and distributed in an .msi package when it is finished), added all the dependencies according to this article (end even more poi jar files) to the classpath and still I am getting the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/math3/util/ArithmeticUtils

It seems that there are more dependencies that the poi-4.1.2.jar file does not contain. Can I add them by hand or will it require more dependencies after that? And where do I have to look. (org.apache.commons.*)

As said building this project with Maven is not an option.

Here are all the imports I have in my class that fails to compile:

import java.io.File; import java.io.FileInputStream; 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.hssf.usermodel.HSSFWorkbook; 

And those are the jar files added to the Libraries in NetBeans

poi-4.1.2.jar poi-excelant-4.1.2.jar poi-ooxml-4.1.2.jar poi-ooxml-schemas-4.1.2.jar xmlbeans-3.1.0.jar 
2

1 Answer

You can look on the website what dependency you need for general operations. Still, for me it seems, that all the import-dependecy are correct. Maybe the dependencies are not correctly added?

Every dependency can be added per hand, even those you mentioned in your post. There are two options:

  1. add the dependency via POM (this one I cannot tell in more detail)
  2. in Projects Structure: go to Modules, then Dependency. Here you can add any dependency vial MAVEN PROJECT library. In your case just write org.apache.poi in the search field, click the search button and look up the list of dependency you need. Here is a picture of the last step without the list, the screenshot did not allow it.enter image description here

Also, it can even happen, that your setting in the project structure is not correct. When I did everything, the dependecies were added with the Scope of "Compile", like in the picture enter image description here

I did the whole procedure in IntelliJ, but it should be quite the same in all other IDE's.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like