Java 异常:Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/compress/archivers/zip/ZipFile 解决方法
这个异常表明缺少 org.apache.commons.compress.archivers.zip.ZipFile 类,可以通过以下步骤解决:
-
下载 Apache Commons Compress 库,可以从官网下载:https://commons.apache.org/proper/commons-compress/download_compress.cgi
-
将下载的压缩包解压,得到 commons-compress-x.y.z.jar 文件(x.y.z 为版本号)
-
将该文件添加到项目的 classpath 中,可以通过以下两种方式之一实现:
a) 在项目中新建一个 lib 目录,将该 jar 文件复制到该目录下,然后在 Eclipse 中右键点击该 jar 文件,选择 Build Path -> Add to Build Path,或者手动在项目的 Properties -> Java Build Path 中添加该 jar 文件。
b) 在项目的 pom.xml 中添加以下依赖:
org.apache.commons commons-compress x.y.z -
重新运行程序,应该可以正常执行了。
原文地址: https://www.cveoy.top/t/topic/oKuv 著作权归作者所有。请勿转载和采集!