My code compiles fine, but I'm gettting a runtime error on this line:
File myFile = new File(FilenameUt开发者_运维百科ils.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.
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.
Check this out from the NetBeans tutorial
Basically, you are going to add a JAR file (a library, the commons.apache.org IO one) to your project "properties" classpath.
If you were to run your packaged project from the command line, you could specify classpath like this:
java -cp apache-io.jar myproject.jar
You might have the jar in your developen environment classpath, but you need it in your runtime classpath
精彩评论