import org.apache.commons.io.FilenameUtils;
public class Test {
public static void main(String[] args) throws InterruptedException {
System.out.println(FilenameUtils.getExtension("a.zip"));
}
}
as shown above, the simple code relies on the commons-io.jar package
compile command:
javac-cp commons-io-2.4.jar-d. Test.java
compiled successfully!
execute the command:
java-cp commons-io-2.4.jar Test
error:
error: the main class Test cannot be found or cannot be loaded
change to the specified directory:
java-cp. Test
error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/io/FilenameUtils
at Test.main(Test.java:6)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.FilenameUtils
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
excuse me, what is the cause?