Bart Friederichs
Bart Friederichs

Reputation: 33511

ClassNotFoundException, even though the containing JAR is part of the build

I am getting a ClassNotFoundException on a class (HSSFWorkbook) that is included in a JAR that is included in my build. The JAR is listed in this list (I am using Eclipse):

Project -> Properties -> Java Build Path -> Libraries

I have tried removing and adding it again, to no avail.

My code is as follows:

// ...
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
// ...

public class XLSWorkbook {
    private HSSFWorkbook wb = null;

    // ...
    public XLSWorkbook() {
        wb = new HSSFWorkbook();
    }
}

And the exception is thrown when I try to instantiate the XLSWorkbook class. The JAR I am using is the POI library from Apache (to be precise: poi-3.8-20120326.jar).

Upvotes: 4

Views: 696

Answers (2)

Dims
Dims

Reputation: 51039

What class is not found? Looks like you are developing for Android. This means classpath at runtime is not the same as at build time. You can have all your jars in place while compiling while this can be wrong while running.

Upvotes: 1

Blackbelt
Blackbelt

Reputation: 157447

Since ADT-18 (I am not sure about the version), external jar libraries have not to be included explicitly. You should put it inside the libs folder . ADT will provide to import they for you. So you should remove the libraries from Project -> Properties -> Java Build Path -> Libraries

Upvotes: 7

Related Questions