I am trying to create a runnable JAR file from a project of which I'm importing org.apache.commons.io. I tried exporting and checked the box to include all dependant libraries but I keep getting this output:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/io
/filefilter/TrueFileFilter
        at tvSort.Main.main(Main.java:36)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.filefilter.Tr
ueFileFilter
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 1 more

Any help would be appreciated, thank you.

有帮助吗?

解决方案

Did you try setting up classpath in the Manifest?

e.g. Class-Path: commons-io-xyzversion.jar

If you can please try to add this manifest entry manually by saving this in a text file and adding it via the jar tool.

Hopefully eclipse has already done this,so did you run the jar with dependencies(jars) in the same folder/path?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top