java.lang.NoClassDefFoundError: org/apache/log4j/Logger 错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38606518/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 03:34:55  来源:igfitidea点击:

java.lang.NoClassDefFoundError: org/apache/log4j/Logger error

javaapache-poi

提问by Danie van der Bank

So I got a request converting xls to xlsx. After a few hours of researching all sites and solutions I managed to adapt some code i found on various site... Now I am stuck with a java.lang.NoClassDefFoundError: org/apache/log4j/Logger

所以我收到了一个将 xls 转换为 xlsx 的请求。在研究了所有站点和解决方案几个小时后,我设法调整了我在各个站点上找到的一些代码......现在我陷入了困境java.lang.NoClassDefFoundError: org/apache/log4j/Logger

here is a list all my libs i am using to get this working so far, I had to add a few libs just to get this far and now i am stuck.

这是一个列表,我目前使用的所有库都是为了让它工作,我不得不添加一些库才能做到这一点,现在我被卡住了。

dropbox-core-sdk-1.7.7,
itextpdf-5.3.0,
Hymanson-core-2.2.4,
PDFBox-0.7.3,
poi-3.10-FINAL-20140208,
poi-ooxml-3.5-beta5,
poi-ooxml-schemas-3.10-beta1,
rs2xml,
slf4j-api-1.7.5,
sqlite,
sqlite-jdbc-3.8.7,
xmlbeans

Below is my code where i call he class

以下是我称他为班级的代码

private void exportRepBtnActionPerformed(java.awt.event.ActionEvent evt) {                                             
    connect();       
    exportRepairReport();
    // This is where I am trying to convert the xls file
    convertExcelFiles.convertWorkbookHSSFToXSSF(workbook);
    //
    int selectedOption = JOptionPane.showConfirmDialog(null,
            "Generate Comprehensive Report?",
            "OPTIONAL",
            JOptionPane.YES_NO_OPTION);

    if (selectedOption == JOptionPane.YES_OPTION) {
        exportRawRepairs();
    }

} 

Hers is the class where things go south.

她是事情向南的班级。

public static XSSFWorkbook convertWorkbookHSSFToXSSF(HSSFWorkbook source) 
{
    XSSFWorkbook retVal = new XSSFWorkbook();
        for (int i = 0; i < source.getNumberOfSheets(); i++) 
        {
            XSSFSheet xssfSheet = retVal.createSheet();
            HSSFSheet hssfsheet = source.getSheetAt(i);
            copySheets(hssfsheet, xssfSheet);
        }
    return retVal;
}

Any help will be appreciated, let me know if you need more info.

任何帮助将不胜感激,如果您需要更多信息,请告诉我。

Thanks in advance.

提前致谢。

回答by Jens

You have to add the log4j<version>.jarto your classpath.

您必须将log4j<version>.jar加到您的类路径中。

回答by pkpk1234

You should add log4j.jar to your classpath

您应该将 log4j.jar 添加到您的类路径中