Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What can cause java.lang.NoClassDefFoundError?

Tags:

java

My code compiles fine, but I'm gettting a runtime error on this line:

File myFile = new File(FilenameUtils.concat(basePath, localPath));

The error thrown is:

java.lang.NoClassDefFoundError: org/apache/commons/io/FilenameUtils

Why would the code compile if it can't resolve a class?

Thanks for any advice.

like image 556
MalcomTucker Avatar asked Feb 10 '10 15:02

MalcomTucker


1 Answers

You should add commons-io library to your runtime classpath.

http://commons.apache.org/io/

In NetBeans Project Properties Window, you click Libraries in the left panel, and in the right panel are 4 categories of classpath you can configure. You should update your Run path or make sure Compile contains commons-io library.

like image 186
uthark Avatar answered Sep 29 '22 08:09

uthark