简体   繁体   中英

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).

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM