No class def find error
- by John Smith
I have the following piece of code which helps me to read the paths of all the files in a directory and its subdirectories :
File dir = new File("directory path");
try {
System.out.println("Getting all files in " + dir.getCanonicalPath() + " including those in subdirectories");
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
List<File> files = (List<File>) FileUtils.listFiles(dir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
for (File file : files) {
try {
System.out.println("file: " + file.getCanonicalPath());
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
The problem is that I get a java.lang.NoClassDefFoundError: org/apache/commons/io/filefilter/TrueFileFilter error.
I've imported the necessary libraries. I mention that I work on a plugin project. This code runs in a class with main function. I don't understand why it gave me this error.
Thank you !