I’ve encounted an error trying to implement Apache commons-compress in my Java application:
java.lang.ClassNotFoundException: org.apache.commons.compress.archivers.ArchiveEntry”
I have the exact same issue described in this post, except I’m not using Bukkit (whatever that is). The [expletive] OP left an infuriating last post, “Regardless, I found a solution. Case closed!” instead of sharing the solution, so I have no idea what (s)he did to resolve it.
I’m not using ArchiveEntry, but rather, TarArchiveEntry, which I assume imports ArchiveEntry. Even if I import the supposedly missing class, Eclipse warns of an unused import. Curiously, if I remove my TarArchiveEntry import, the warning disappears, but the line containing the reference to TarArchiveEntry errors.
I’ve never experienced this issue before. It would seem that the TarArchiveEntry class contains an error and fails to import ArchiveEntry, but I can’t see a widely used library such as apache commons containing such an elementary error.
Is there anything wrong with my implimentation?
There was indeed a problem with my classpath. In my project directory, I added the following line to the .classpath file (it’s hidden, so look closely):
After adding this line, I no longer get ClassNotFoundException. I’m not sure why this fixed the problem, since I’m using several other libraries (e.g. commons-fileupload-1.2.jar) that aren’t found in my .classpath file that don’t throw any exceptions as a result.
My question now is, why didn’t Eclipse modify this file when I added the jar to the buildpath within Eclipse? Also, why did I need to add commons-compress, but not commons-fileupload to my .classpath file?